Highcharter R Package Essentials for Easy Interactive Graphs

Highchart Interactive Boxplot in R

Intrduction

This article describes how to create an interactive boxplot in R using the highcharter R package.



Contents:

Loading required R packages

# Load required R packages
library(dplyr)
library(highcharter) 
# Set highcharter options
options(highcharter.theme = hc_theme_smpl(tooltip = list(valueDecimals = 2)))

Data preparation

data("ToothGrowth")
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
head(ToothGrowth, 4)
##    len supp dose
## 1  4.2   VC  0.5
## 2 11.5   VC  0.5
## 3  7.3   VC  0.5
## 4  5.8   VC  0.5

Horizontal boxplots

hc <- hcboxplot(
  x = ToothGrowth$len,
  var = ToothGrowth$dose,
  name = "Tooth Length", 
  color = "#2980b9"
  ) 
hc

Vertical boxplots

hc <- hcboxplot(
  x = ToothGrowth$len,
  var = ToothGrowth$dose,
  outliers = FALSE,
  color = "#2980b9"
  ) %>% 
  hc_chart(type = "column")
hc

Grouped boxplots

hc <- hcboxplot(
  x = ToothGrowth$len,
  var = ToothGrowth$dose,
  var2 = ToothGrowth$supp,
  outliers = FALSE
  ) %>% 
  hc_chart(type = "column")
hc



Version: Français

Highchart Interactive Scatter Plot in R (Prev Lesson)
(Next Lesson) Highchart Interactive Line Plot in R
Back to Highcharter R Package Essentials for Easy Interactive Graphs

No Comments

Give a comment

Want to post an issue with R? If yes, please make sure you have read this: How to Include Reproducible R Script Examples in Datanovia Comments