Can a mean line graph be plotted along with boxplot using highcharter.

The code below gives no output.

highchart() %>% 
    hc_add_series_boxplot(x = xx , by = xy, name = "name") %>%
    hc_add_series( df, "line", hcaes(x = mean, y = xy))

The highcharter package has a shortcut function, hcboxplot(), that can help you make a boxplot.

The image won't show up correctly in a reprex (because of the way that highcharts animate their layout), but you can add a mean line for all the boxplots by using one of the axis functions (depending on how your chart is oriented), and, in essence, adding a new "series" of data to draw the line over the chart.

library(highcharter)
#> Highcharts (www.highcharts.com) is a Highsoft software product which is
#> not free for commercial and Governmental use
data(diamonds, package = "ggplot2")

plotline <- list(
  color = "red", value = mean(diamonds$x), width = 2, zIndex = 5
)

hcboxplot(
  x = diamonds$x, var = diamonds$color,
  name = "Length", color = "#2980b9"
) %>%
  hc_yAxis(plotLines = list(plotline))

Created on 2019-04-09 by the reprex package (v0.2.1)

Here's what it looks like from a screenshot:

The example above is a modified version of one of the charts in the highcharter showcase:
http://jkunst.com/highcharter/showcase.html

If this isn't what you had in mind, could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.

install.packages("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

There's also a nice FAQ on how to do a minimal reprex for beginners, below:

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.