# data.frame
df <- data.frame(
  x = 1:100,
  y = rnorm(100, 20, 12)
)

Histogram

df %>% 
  e_charts() %>% 
  e_histogram(y) %>% 
  e_tooltip()

Density

Plot the density on a different Y axis as its range differs much from the that of the histogram.

df %>%
  e_charts() %>% 
  e_histogram(y) %>% 
  e_density(y, name = "density", areaStyle = list(opacity = .4), 
            smooth = TRUE, y.index = 1) %>% 
  e_tooltip()

Fit

Functions leverage R buil-in:

  • lm
  • glm
  • loess

Linear

df %>% 
  e_charts(x) %>% 
  e_scatter(y) %>% 
  e_lm(y ~ x)

Generalised Linear

CO2 %>% 
  e_charts(conc) %>% 
  e_scatter(uptake) %>% 
  e_glm(uptake ~ conc, name = "GLM")

Polynomial

mtcars %>% 
  e_charts(disp) %>% 
  e_scatter(mpg) %>% 
  e_loess(mpg ~ disp)