Bill Bachman
2006-Nov-08 17:23 UTC
[R] can Rgui.exe be launched with a script as an argument?
Ultimately, I would like to launch R (from another application) with a script as an argument that creates a plot. I am running on Windows XP with R 2.4.0. I currently can do this with S-Plus from my application by giving this command: ?C:\Program Files\Insightful\splus62\cmd\splus.exe? S_PROJ=?C:\myproject? ?C:\myproject\myscript.ssc? I would like to be able to port my scripts to R and use R to keep costs low for academics, etc. The closest that I have been able to come to doing this in R is to create a .First function: .First <- function() source("test.R?) The test.R file contains the following lines: a<-c(1,2,3,4) b<-c(1,4,9,16) plot(a,b) The error on launching rgui.exe with a batch file ("C:\Program Files\R\R-2.4.0\bin\Rgui.exe " -?quiet) is: Error in eval.with.vis(expr, envir, enclos) : ??????? could not find function "plot" (any other high level function also does not work) Any suggestions greatly appreciated. Thanks, Bill
Lanre Okusanya
2006-Nov-08 18:04 UTC
[R] can Rgui.exe be launched with a script as an argument?
I assume this is windoze. Have you considered using the Rterm? You can have in your script the plot to be created as an eps file Lanre Bill Bachman wrote:> Ultimately, I would like to launch R (from another application) with a > script as an argument that creates a plot. I am running on Windows XP with > R 2.4.0. I currently can do this with S-Plus from my application by giving > this command: > > ?C:\Program Files\Insightful\splus62\cmd\splus.exe? S_PROJ=?C:\myproject? > ?C:\myproject\myscript.ssc? > > I would like to be able to port my scripts to R and use R to keep costs low > for academics, etc. > > The closest that I have been able to come to doing this in R is to create a > .First function: > > .First <- function() source("test.R?) > > The test.R file contains the following lines: > > a<-c(1,2,3,4) > b<-c(1,4,9,16) > plot(a,b) > > The error on launching rgui.exe with a batch file ("C:\Program > Files\R\R-2.4.0\bin\Rgui.exe " -?quiet) is: > > Error in eval.with.vis(expr, envir, enclos) : > could not find function "plot" > > (any other high level function also does not work) > > Any suggestions greatly appreciated. > > Thanks, > Bill > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >
Hans-Peter
2006-Nov-08 20:04 UTC
[R] can Rgui.exe be launched with a script as an argument?
2006/11/8, Lanre Okusanya <lanre.okusanya at gmail.com>:> I assume this is windoze. Have you considered using the Rterm? You canwindows... afaic try with R.exe or, as said and imho better, Rterm.exe. Examples testR.bat: set cmd=C:\Programme\R\R-2.3.1\Bin\R.exe call %cmd% CMD BATCH --slave --vanilla --args "sayHello.R" "rout.txt" testT.bat: set cmd=C:\Programme\R\R-2.3.1\Bin\Rterm.exe call %cmd% --vanilla < sayHello.R > rtermout.txt sayHello.R: cat( "hello chappi\n" ) q() -- Regards, Hans-Peter
Bill Bachman
2006-Nov-08 20:35 UTC
[R] can Rgui.exe be launched with a script as an argument?
Thank you to Paul Murrell for a solution: # test.R require(graphics) a<-c(1,2,3,4) b<-c(1,4,9,16) plot(a,b) -----Original Message----- From: Lanre Okusanya [mailto:lanre.okusanya at gmail.com] Sent: Wednesday, November 08, 2006 1:04 PM To: Bill Bachman Cc: r-help at stat.math.ethz.ch Subject: Re: [R] can Rgui.exe be launched with a script as an argument? I assume this is windoze. Have you considered using the Rterm? You can have in your script the plot to be created as an eps file Lanre Bill Bachman wrote:> Ultimately, I would like to launch R (from another application) with a > script as an argument that creates a plot. I am running on Windows XP > with R 2.4.0. I currently can do this with S-Plus from my application > by giving this command: > > "C:\Program Files\Insightful\splus62\cmd\splus.exe" S_PROJ="C:\myproject" > "C:\myproject\myscript.ssc" > > I would like to be able to port my scripts to R and use R to keep > costs low for academics, etc. > > The closest that I have been able to come to doing this in R is to > create a .First function: > > .First <- function() source("test.R") > > The test.R file contains the following lines: > > a<-c(1,2,3,4) > b<-c(1,4,9,16) > plot(a,b) > > The error on launching rgui.exe with a batch file ("C:\Program > Files\R\R-2.4.0\bin\Rgui.exe " --quiet) is: > > Error in eval.with.vis(expr, envir, enclos) : > could not find function "plot" > > (any other high level function also does not work) > > Any suggestions greatly appreciated. > > Thanks, > Bill > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >