Export plot form Rstudio into excel editable form?

53 views Asked by At

I have few plot from Generalized additive model(GAM) and MULTI variable additive models(MARs) including partials plots with 95% confidence index and a 3d plot of two most influential variable and its effect on output. The journal I'm submitting is asking for MS excel graphs and editable in MS excel. So how do I plot these the graphs in excel?

Export graphs in excel editable form, but ended in exporting in image form.

1

There are 1 answers

0
Stéphane Laurent On

The mscharts package has already been mentionned in the comments.

The rvg package is more flexible because it allows to render an Excel chart from any R plot (I think a ggplot is possible - to try).

Here is how to create a dml file:

library(rvg)
dml_xlsx(file = "excelChart.dml")
plot(1:11, (-5:5)^2, type = "b", main = "Simple Example")
dev.off()

However I didn't found how one can visualize this file and how to convert it to a picture.

You can create an Excel sheet with an embedded chart as follows:

library(rvg)
library(officer)
my_ws <- read_xlsx()
my_ws <- xl_add_vg(
  my_ws,
  sheet = "Sheet1",
  code = barplot(1:5, col = 2:6), width = 6, height = 6, left = 1, top = 2
)
fileout <- "excelChart.xlsx"
print(my_ws, target = fileout)

Then right-click on the chart and you can save it as a picture.