需要一些关于R库XLConnect的帮助



我正在尝试使用XLConnect将图形和图表从R代码复制到Excel格式的文件。我收到一个错误"错误:非法参数异常(Java(:名称'Report2'不存在!"指出选项卡"Report2"不存在。但是,我在代码中使用:"XLConnect::createSheet(wb,名称="Report2"("创建了选项卡。

当我能够将文本和表格从 R 复制到选项卡"Report2"但无法将图表复制到同一选项卡时,为什么无法在同一选项卡中复制图形/图表。

wb <- loadWorkbook("Data Quality Report2.xls", create = TRUE)
XLConnect::createSheet(wb, name = "Report2")
require(lattice)
png(filename = "earthquake.png", width = 800, height = 600)
devAskNewPage(ask = FALSE)
Depth <- equal.count(quakes$depth, number=8, overlap=.1)
xyplot(lat ~ long | Depth, data = quakes)
update(trellis.last.object(),
       strip = strip.custom(strip.names = TRUE, strip.levels = TRUE),
       par.strip.text = list(cex = 0.75),
       aspect = "iso")
dev.off()
addImage(wb, filename = "earthquake.png", name = "Report2",originalSize = TRUE)
您需要

在调用addImage时指定命名范围的名称(例如通过createName创建(。有关完整示例,请参阅 https://www.rdocumentation.org/packages/XLConnect/versions/0.2-15/topics/addImage-methods。

最新更新