Re: [R] script works in Rstudio but not with Rscript

2015-04-08 Thread Henrik Bengtsson
On Wed, Apr 8, 2015 at 11:20 AM, Milt Epstein wrote: > OK, this suggestion brings up some interesting results. No solution, > however. But it's interesting ... and maybe some helpful leads. > > The basic/short answer to your question is no, it doesn't work with "R > -f script". > > The longer an

Re: [R] script works in Rstudio but not with Rscript

2015-04-08 Thread William Dunlap
> > args <- commandArgs(TRUE) > > num <- args[1] and then you get a complaint about something not being numeric. commandArgs() returns a character vector so try num <- as.numeric(args[1]) and you may as well preface it with stopifnot(length(args)>0) Bill Dunlap TIBCO Software wdunlap tibco

Re: [R] script works in Rstudio but not with Rscript

2015-04-08 Thread Milt Epstein
OK, this suggestion brings up some interesting results. No solution, however. But it's interesting ... and maybe some helpful leads. The basic/short answer to your question is no, it doesn't work with "R -f script". The longer answer: Note that the script is currently set up to be called with a

Re: [R] script works in Rstudio but not with Rscript

2015-04-08 Thread Henrik Bengtsson
Does it work with R -f script? If so, then it's because Rscript does not attaching methods package by default, but R does. Try loading methods at the top of your script. My $.02 Henrik On Apr 8, 2015 07:41, "Milt Epstein" wrote: > Greetings. I am new to R, but have quite a bit of experience >

[R] script works in Rstudio but not with Rscript

2015-04-08 Thread Milt Epstein
Greetings. I am new to R, but have quite a bit of experience programming with other languages (e.g., Perl, Java, Python, shell scripting). I'm now working on a project where I need to use R. A colleague wrote a number of small scripts that work fine in Rstudio, but a couple of them don't work wh