简体   繁体   English

使用 openxlsx 导出 R 数据框时出错(“zipr 中的错误”)

[英]Error when exporting R data frame using openxlsx ("Error in zipr")

Usually I'm using the openxlsx package and the write.xlsx function when exporting R data frames into .xlsx-files.通常我在将 R 数据帧导出到 .xlsx 文件时使用 openxlsx 包和 write.xlsx 函数。 Since yesterday - probably after I was using the package XLConnect - something got messed up and the write.xlsx function doesn't work anymore.从昨天开始——可能是在我使用了 XLConnect 包之后——有些事情搞砸了,write.xlsx 函数不再工作了。 This is the error I get:这是我得到的错误:

Error in zipr(zipfile = tmpFile, include_directories = FALSE, files = list.files(path = tmpDir, : unused argument (include_directories = FALSE) zipr 中的错误(zipfile = tmpFile,include_directories = FALSE,files = list.files(path = tmpDir,:未使用的参数(include_directories = FALSE)

Unfortunately, I don't understand what this error means.不幸的是,我不明白这个错误是什么意思。 Thanks for any helpful advice.感谢您提供任何有用的建议。

Edit: The function works when I use an older openxlsx version (4.1.0).编辑:当我使用较旧的 openxlsx 版本 (4.1.0) 时,该功能有效。

I was getting the same error.我遇到了同样的错误。

I think the problem is with dependencies of openxlsx.我认为问题在于 openxlsx 的依赖关系。 There is a "zipR" package that might be picked up when you install openxlsx, while the actual dependency is zip package:安装 openxlsx 时可能会选择一个“zipR”包,而实际依赖项是 zip 包:

I installed "zip" along with openxlsx and I don't get the error anymore.我与 openxlsx 一起安装了“zip”,但不再出现错误。

I do not really understand the error message here.我不太明白这里的错误信息。 My computer does not allow me to save files to "c:/".我的电脑不允许我将文件保存到“c:/”。 So, if remove "c:/" part, it works fine, to save the file to the current working directory.因此,如果删除“c:/”部分,它可以正常工作,将文件保存到当前工作目录。

library(openxlsx)
df <- data.frame('x' = c(1,2,3),
                 'y' = c(3,2,1))
openxlsx::write.xlsx(df, "test.xlsx")

You would also try another package: writexl您还可以尝试另一个包: writexl

writexl::write_xlsx(df, "text5.xlsx")`

This works on my machine.这适用于我的机器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM