[R] source("filename") vs. input from command-line

Alex Buerkle cbuerkle at bio.indiana.edu
Thu Apr 22 17:07:30 CEST 1999


On Wed, 21 Apr 1999, Alex Buerkle wrote:
> When I source("tmp.r") a file from within R, the code executes without
> error. When I launch with 'R --no-save --no-restore < tmp.r', the code
> sometimes appears to cause some type of buffer overflow and nothing gets
> executed.

BR> Version? OS?  On my R-0.64.0 on Solaris I can do this ...

I am using R-0.63.3 on linux-x86.

> It appears that when the vector is long, say 121 x 17 digits numbers, the
> new line character is not recognized, because R prints a newline, but puts
> the '+' continuation symbol on the next line, and does so for each
> subsequent line, as follows ...

BR> The NL is only used to break up input: this is saying that what it
BR> has seen so far is syntactically incomplete.  Is this a standard
BR> Unix text file (if you are on Unix)?

It is a standard text file.  If it were syntactially incomplete, sourcing
it from the R prompt would fail, but it doesn't.

> ... 0.673485477583901, 0.492934866805126, 0.67+ 97955088067,
> 0.359755098747052, 0.734365384276714, 0.776102576892879, 1)
> + Dmatrix <- matrix (mydata, byrow=TRUE, nrow=11, ncol=11 )
> + result<-eigen(Dmatrix)
> + varEig<-var(result$values)
> + cat (c('variance of the eigenvalues:', varEig), fill=TRUE)

> When the list is shorter, I don't get this problem.

What I have ended up doing is calling R from PERL or the command line
with the following:

echo "source ('tmp0.r')" | R --no-save --no-restore

This works.  

I am still not clear on why the command-line redirection did not work
(R --no-save --no-restore < tmp.r).  Is there a difference between how
R handles input received from a unix pipe versus from redirection?

- Alex

~^^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
C. Alex Buerkle                 Ph:  812-855-9018
Jordan Hall 142                 Fax: 812-855-6705
Department of Biology		
Indiana University
Bloomington, IN 47405    cbuerkle at bio.indiana.edu


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list