简体   繁体   中英

Strange interaction between R package XLConnect and choose.files()

I observe the following strange behaviour:

Using the R-console (2.15.2, Windows 7, 32 bit), I get:

> choose.files() # works fine here
character(0)
> library(XLConnect)
Lade nötiges Paket: XLConnectJars
Lade nötiges Paket: rJava
Error : .onLoad in loadNamespace() für 'XLConnectJars' fehlgeschlagen, Details:
  Aufruf: .jinit()
  Fehler: Cannot create Java virtual machine (-4)
Zusätzlich: Warnmeldung:
Paket ‘rJava’ wurde unter R Version 2.15.3 erstellt 
Fehler: Paket ‘XLConnectJars’ konnte nicht geladen werden

The choose.files() call works fine (I just clicked "Cancel"), but obviously XLConnect could not be loaded due to some JVM related problem.

Now, restarting the R-console and issuing the same two commands in different order:

> library(XLConnect)
Lade nötiges Paket: XLConnectJars
Lade nötiges Paket: rJava
XLConnect 0.2-4 by Mirai Solutions GmbH
http://www.mirai-solutions.com ,
http://miraisolutions.wordpress.com
Warnmeldung:
Paket ‘rJava’ wurde unter R Version 2.15.3 erstellt 
> choose.files() # returns after a few seconds without ever displaying a file choser
character(0)

So the XLConnect package loads fine, but the choose.files() call never displays a file chooser and returns "character(0)" after some seconds. When I run the same code in R-Studio, everything works fine in both ways.

I already tried to increase the Java heap space (as I found this hint in some other threads/forums) but it did not help.

Any explanations or tips how to solve that problem?

This issue is most likely related to R 2.15.2's change in C stack size (increase to 64MB - also for Win 32-bit systems; see https://stat.ethz.ch/pipermail/r-announce/2012/000557.html ). That also explains why you observe the issue in R 2.15.3 but not in R 2.15.0.

The "increase in C stack size" issue is also the one that is discussed at https://stat.ethz.ch/pipermail/r-devel/2013-January/065576.html and on the RStudio support forums.

Possible ways to overcome the issue:

  • use the latest version of R where this is fixed (R 3.0+; recommended), or alternatively an earlier version (eg R 2.15.0; not recommended)
  • use a recent/latest version of RStudio (where they set the stack size on their end; this was actually done as a result of issues described with the C stack size change in R 2.15.2)
  • try to set the java stack size manually BEFORE using/loading any Java-related packages in R; eg options(java.parameters = "-Xss5m") or options(java.parameters = "-Xss10m")

安装版本3.02的R为我解决了同样的问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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