我在 Ubuntu 16.04 的 R Shiny 服务器上有 2 个正在运行的应用程序。两者都进行一些数据操作(例如清理、连接表等),然后将输出转储为具有类似功能的 Excel 文件,
dumpExcel <- function(matched, non_matched=NULL, fileName, out_format='xlsx') {
if (out_format == 'xlsx') {
library(openxlsx)
output <- createWorkbook()
addWorksheet(output, "matched")
if (!(is.null(non_matched))) { addWorksheet(output, "non_matched") }
writeData(output,"matched", matched, colNames = T)
if (!(is.null(non_matched))) { writeData(output,"non_matched", non_matched, colNames = T) }
FileName = fileName
saveWorkbook(output, FileName, overwrite = T)
return(output)
} else if (out_format == 'csv') {
write.csv(matched, gsub('.xlsx', '.csv', fileName), row.names=F)
}
}
对于第一个应用程序,此功能完美运行。对于第二个,它工作得很好,但不知何故现在不是,并在下面抛出错误,
Error in : zipping up workbook failed. Please make sure Rtools is installed or a zip application is available to R.
Try installr::install.rtools() on Windows. If the "Rtools\bin" directory does not appear in Sys.getenv("PATH") please add it to the system PATH
or set this within the R session with Sys.setenv("R_ZIPCMD" = "path/to/zip.exe")
我尝试添加行
Sys.setenv(R_ZIPCMD = "/usr/bin/zip")
之前,它没有用。这个应用程序为什么会抛出这个错误,而同一服务器/机器中的另一个却运行良好?任何帮助都非常感谢...
最佳答案
尝试添加Sys.setenv(R_ZIPCMD = "/usr/bin/zip")
在 server.R 中(在加载库之后,在 shinyServer(function(...
block 之前。这对我有用。
关于R Shiny "R_ZIPCMD"路径压缩错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42729218/