Exporting data from R into an Excel File that contains a graphic with additional text causes the graphic to be deleted

那年仲夏 提交于 2021-01-29 06:50:47

问题


I have trouble when exporting data from R into an Excel file containing a graphic with additional text.

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 openxlsx option

Fichier <- loadWorkbook("File.xlsx")
writeData(Fichier, sheet="D.Brutes", MWE , colNames=T)
saveWorkbook(Fichier,"File.xlsx",overwrite=T)

Now 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, until I add some text on the graphics (e.g. "source : Eurostat"), which then tells me that (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

This problem happens whether the graphic is on the separate sheet or on the same one.

Is it something only I experience ? What could be the cause and how could I get around that ?

来源:https://stackoverflow.com/questions/64756679/exporting-data-from-r-into-an-excel-file-that-contains-a-graphic-with-additional

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!