I have trouble when exporting data from R into an Excel file that contains a graphic with additional text inserted.
The problem is relatively specific.
So I have a
datatable in R, like this one :
library(lubridate) library(dplyr) library(data.table) library(openxlsx) Sys.setenv(LANGUAGE='en') MWE <- data.table( Date=rep(seq(ymd("2020-1-1"), ymd("2020-3-30"), by = "days")), Country1=rnorm(90,2,3), Country2=rnorm(90,2,3))
I then export it in an Excel file using an
Fichier <- loadWorkbook("File.xlsx") writeData(Fichier, sheet="Data", MWE , colNames=T) saveWorkbook(Fichier,"File.xlsx",overwrite=T)
This datatable, now in an Excel sheet, is used to create a graph (two curves with the values for Country 1 and Country 2 over time), in a separate sheet.
Everything works, as long as there is no additional text on the graph (option insert text). When I do so (e.g. to mention sources), then I get the following error (approximate translation) :
We have encountered a problem with the file "file.xlsx" but we can try to retrieve the maximum amount of information. If this file is reliable, click on yes.
Then I get the following message and the graphic is deleted
First is it a problem specific to me ?
And if not what could be the cause and how could I get around that ?