Re: [Rd] Rscript fails with some packages (for example, h5)

2017-12-27 Thread Duncan Murdoch
On 27/12/2017 9:11 AM, Sun Yijiang wrote: Thanks for the details. I’m new to R, and I’m not blaming anything here, just that I’m still not clear what good it makes to keep this inconsistency between R and Rscript. To me (and probably to many others from Perl/Python etc.), this is shockingly weird

Re: [Rd] Rscript fails with some packages (for example, h5)

2017-12-27 Thread Sun Yijiang
Thanks for the details. I’m new to R, and I’m not blaming anything here, just that I’m still not clear what good it makes to keep this inconsistency between R and Rscript. To me (and probably to many others from Perl/Python etc.), this is shockingly weird. I can live with that, and I also want to k

Re: [Rd] Rscript fails with some packages (for example, h5)

2017-12-27 Thread Dirk Eddelbuettel
Duncan, Very nice tutorial. However it does NOT take away from the fact that _very_ simple_ scripts (like the one posted by Sun at the beginning of this thread) simply _fail_ in error under Rscript. Whereas they don't under R or r. The R environment ships an interpreter meant for command-line a

Re: [Rd] Rscript fails with some packages (for example, h5)

2017-12-27 Thread Duncan Murdoch
On 26/12/2017 9:40 AM, Dirk Eddelbuettel wrote: On 26 December 2017 at 22:14, Sun Yijiang wrote: | Thanks for the solution. Now I know the work-arounds, but still don't | quite get it. Why does R_DEFAULT_PACKAGES has anything to do with | library(methods)? Because it governs which packages are

Re: [Rd] Rscript fails with some packages (for example, h5)

2017-12-26 Thread Sun Yijiang
Hi Dirk, Thanks for the solution. Now I know the work-arounds, but still don't quite get it. Why does R_DEFAULT_PACKAGES has anything to do with library(methods)? If library(h5) works, it should just work, not depend on an environment variable. Rscript is not consistent with R, that's my confus

Re: [Rd] Rscript fails with some packages (for example, h5)

2017-12-26 Thread Dirk Eddelbuettel
On 26 December 2017 at 22:14, Sun Yijiang wrote: | Thanks for the solution. Now I know the work-arounds, but still don't | quite get it. Why does R_DEFAULT_PACKAGES has anything to do with | library(methods)? Because it governs which packages are loaded by default. And while R also loads 'metho

Re: [Rd] Rscript fails with some packages (for example, h5)

2017-12-26 Thread Dirk Eddelbuettel
On 26 December 2017 at 15:24, Sun Yijiang wrote: | After looking into C source code, I found that Rscript by default fills | environment variable R_DEFAULT_PACKAGES with | "datasets,utils,grDevices,graphics,stats", and it somehow fails some | package like h5. | | The problem here is, not setting

[Rd] Rscript fails with some packages (for example, h5)

2017-12-26 Thread Sun Yijiang
Consider this script (with h5 installed): $ cat test.R library(h5) name <- tempfile() f <- h5file(name) file.remove(name) $ Rscript test.R Error in initialize(value, ...) : cannot use object of class "character" in new(): class "H5File" does not extend that class Calls: h5file -> new -> initia