[R] calling R from cmd line, loading in data sets on the call

John McNeil john at mcneilco.com
Tue Nov 28 18:02:29 CET 2006


I know an answer for Unix that can perhaps you can translate to DOS.  
If you pass a file of R statements to 'R' on the command line it will  
run them. In Unix, the '|' (pipe) symbol sends text to a program as  
though it came from a file, thus:
	echo "x<-2; 2*x" | R --vanilla --slave
yields
	[1] 4

Or you could put "x<-2; 2*x" in a file called test.R and run:
	R --vanilla --slave < test.R

I use this to interpret user commands from labsynch wiki pages on the  
server ( I learned this from Alfredo Pontillo's R-php). You can run  
any R command, including loading other files and libraries. I use it  
to pass files and set the working directory.

John



More information about the R-help mailing list