我几天来一直在研究这个问题,到目前为止,没有一个提供的修复程序对我有用,我希望有人能够提供帮助。
设置:
我正在开发一个项目,其中最后一步是获取Rstudio数据集并将其导出到excel工作簿中,在具有适当名称的单独工作表上包含不同的数据部分。我尝试从一个主要数据集工作并拆分成工作表,我也尝试将数据集拆分为不同的数据子集并从中创建工作表。 (我已经包含了这些信息以防它相关但我不认为问题源于此)我似乎没有问题地完成分裂步骤但是当我尝试将工作表写入.xlsx文件时我得到了压缩工作簿失败错误。 出于显而易见的原因,所有名称都已更改为更通用的名称,但我希望其意图仍然存在。
##Setting up the list Option 1
require(openxlsx)
wbCluster <- list(
"Server1" = Server1
, "Server2" = Server2
, "Server3" = Server3
, "Server4" = Server4
, "Server5" = Server5
, "Server6" = Server6
, "Server7" = Server7
, "Server8" = Server8
, "Server9" = Server9
, "Server10" = Server10
, "Server11" = Server11
, "Server12" = Server12
, "Server13" = Server13
, "Server14" = Server14
, "Server15" = Server15
, "Server16" = Server16
, "Server17" = Server17
, "AllServers" = datadump
)
Option 2:
require(openxlsx)
wbCluster <- list(
"Server1" = subset(ReadyforExportServers, server == "Server1")
, "Server2" = subset(ReadyforExportServers, server == "Server2")
, "Server3" = subset(ReadyforExportServers, server == "Server3")
, "Server4" = subset(ReadyforExportServers, server == "Server4")
, "Server5" = subset(ReadyforExportServers, server == "Server5")
, "Server6" = subset(ReadyforExportServers, server == "Server6")
, "Server7" = subset(ReadyforExportServers, server == "Server7")
, "Server8" = subset(ReadyforExportServers, server == "Server8")
, "Server9" = subset(ReadyforExportServers, server == "Server9")
, "Server10" = subset(ReadyforExportServers, server == "Server10")
, "Server11" = subset(ReadyforExportServers, server == "Server11")
, "Server12" = subset(ReadyforExportServers, server == "Server12")
, "Server13" = subset(ReadyforExportServers, server == "Server13")
, "Server14" = subset(ReadyforExportServers, server == "Server14")
, "Server15" = subset(ReadyforExportServers, server == "Server15")
, "Server16" = subset(ReadyforExportServers, server == "Server16")
, "Server17" = subset(ReadyforExportServers, server == "Server17")
, "AllServers" = datadump
)
等号左边的代码是我想要的工作表名称,右边的代码是我正在处理的rStudio中的数据集。在选项1中,我在R中为我想要的每个工作表创建了一个不同的数据集,在选项2中,这是我从相同的基础数据集中选择并抓取工作表的不同数据切割的地方。
我没有解决这个问题,但是当我尝试将wbCluster写入.xlsx文件时,我遇到了问题。
我试过了两个:
write.xlsx(wbCluster, file = "2_9_2018.xlsx", overwrite = TRUE)
##and
write.xlsx(wbCluster, file = "2_9_2018.xlsx")
我每次都会得到同样的错误。
Error: zipping up workbook failed. Please make sure Rtools is installed or a
zip application is available to R.
Try installr::install.rtools() on Windows.
当我跑步时,给我以下内容:
> installr::install.rtools()
No need to install Rtools - You've got the relevant version of Rtools
installed
我正在与之合作 - R版:3.3.2 - rStudio版本:1.1.414 - openxlsx版本:3.0.0 - rTools版本:34
我尝试卸载rTools并重新安装它,并按照https://github.com/awalker89/openxlsx/issues/111中的建议选中该框。但这并没有解决错误。
我尝试过从github安装
devtools::install_github("awalker89/openxlsx")
如果有可用的新版本尚未按照https://github.com/awalker89/openxlsx/issues/164中的建议在CRAN上使用。但这并没有解决错误。
我还按照Error: zipping up workbook failed when trying to write.xlsx中的建议在Sys.getenv上尝试了一些变体(在每个可能的修复后运行命令写入.xlsx但每次只得到相同的错误)。
Sys.setenv(R_ZIPCMD = "C:/Rtools/bin/zip.exe")
Sys.setenv("R_ZIPCMD" = "path/to/zip.exe")
但它仍然没有出现在我的
中 Sys.getenv("PATH")
如果有人可以帮我解决这个问题,我会非常感激,因为我真的没有办法解决这个问题。