Search code examples
rpowerpointmschartofficer

combo charts in R mschart


Is there a way to create combo charts using mschart. I am trying to create a chart where one column of the data will be a line chart and another column would be a bar chart. The below code doesnt work.

library(tidyverse)
library(mschart)

mtcars %>% 
  as_tibble(rownames = "car") %>% 
  ms_linechart(x="car", y="mpg") %>% 
  ms_barchart(x="car", y = "qsec") %>% 
  print(preview = TRUE)

The error I get is as follows:

Error in mschart::ms_barchart(., x = "car", y = "qsec") : 
  y column should be numeric.

Solution

  • Currently, it is not possible in mschart to create a single figure that simultaneously overlays multiple types of traces onto a single plot. You can create multiple figures in the same page but not the combination figure. However, this is possible with the officer and rvg packages. The drawback of these is that the figure will not be connected to the data, such that a change in the data will affect the figure. However, the figure will nevertheless be editable within Word itself.