[英]Error in ls(envir = envir, all.names = private)?
The below error keeps coming up inconsistently when I try to read excel files into R using the 'XLConnect' package. 当我尝试使用'XLConnect'包将excel文件读入R时,以下错误不断出现。
Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument
I have actually run into this error while even using other packages that read excel files like package 'xlsx' and 'xlsReadWrite'. 我实际上遇到了这个错误,甚至使用其他读取包'xlsx'和'xlsReadWrite'等excel文件的包。 Many times restarting the R session solves this problem, which leads me to think that something else I am doing in my R session is changing the environment and not allowing me to load excel files anymore.
很多时候重新启动R会话解决了这个问题,这让我觉得我在R会话中做的其他事情正在改变环境而不允许我再加载excel文件。 Below is the latest example of code that is causing this error.
下面是导致此错误的最新代码示例。 In this case I know that the following coding sequence is causing the error to appear - but why is that happening?
在这种情况下,我知道以下编码序列导致错误出现 - 但为什么会发生这种情况? And how can I get past this error if I need the chron package.
如果我需要chron包,我怎么能克服这个错误。
library("XLConnect")
wb2 <- loadWorkbook("excel_file", create = FALSE)
library(chron)
wb2 <- loadWorkbook("excel_file", create = FALSE)
Anyone else run into this issue before? 其他人之前遇到过这个问题吗? Any help on this issue is greatly appreciated!
非常感谢任何有关此问题的帮助!
Before reopening the workbook try removing the reference to previously opened one, so: rm(wb2) wb2 <- loadWorkbook("excel_file", create = FALSE) 在重新打开工作簿之前尝试删除对先前打开的工作簿的引用,所以:rm(wb2)wb2 < - loadWorkbook(“excel_file”,create = FALSE)
Also, make sure that "excel_file" is not open by excel or any other program while you run the R test. 此外,确保在运行R测试时excel或任何其他程序未打开“excel_file”。
I've seen the same error come up when using XLConnect and the above seemed to help. 我看到使用XLConnect时出现同样的错误,上面似乎有所帮助。
Had this problem a couple of times and the call stack looks like this message is generated when a "OutOfMemory" Exception is thrown. 有这个问题几次,并且调用堆栈看起来像抛出“OutOfMemory”异常时生成此消息。
To solve this problem I used: 为了解决这个问题,我使用了:
options( java.parameters = "-Xmx4g" )
to increase the heap size rJava is able to use. 增加rJava能够使用的堆大小。
Debugging with options(error=utils::recover)
helped a lot, because the R error messages are not very specific. 使用
options(error=utils::recover)
调试options(error=utils::recover)
有很多帮助,因为R错误消息不是非常具体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.