[R] Why doesnot Rscript work ?

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Dec 14 11:26:10 CET 2009


On Mon, 14 Dec 2009, z_axis wrote:

>
> %cat stock.R
> #! /usr/local/bin/Rscript
>
> args <- commandArgs(TRUE)
> args
>
> x <- read.csv("000301.csv")
> matplot(x[,1],x[,-1],type="l")
> #q(save="no")
>
> %Rscript stock.R 000301.csv
> [1] "000301.csv"
> matplot doesnot draw anything(no drawing window).

Incorrect: it plots on the default device for batch use, most likely 
pdf(), so look for a file Rplots.pdf.

You have ignored the posting guide so we do not know your OS.  On a 
Unix-alike, you could explicitly open X11() (quartz() on a Mac), but 
it would be closed again at the end of your script unless you arrange 
to pause the script.

> Howeve, in R, source works great!
>> source("stock.R")
>
> Sincerely!

Real names and the courtesy of a signature block are preferred here.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list