R-helpers, 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. tmp.r contains: myData<-c(1,0, ... long vector of numbers) followed by a new line character and then some code to operate on myData. 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 ... ... 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. Anyone have any ideas as to what is going on? The reason I am doing this is to call R from a PERL program. Thanks, 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian D Ripley
1999-Apr-22 05:33 UTC
[R] source("filename") vs. input from command-line
On Wed, 21 Apr 1999, Alex Buerkle wrote:> > R-helpers, > > 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.Version? OS? On my R-0.64.0 on Solaris I can do this with 1000 17-digit numbers, so I think there is particular problem with your setup.> tmp.r contains: > myData<-c(1,0, ... long vector of numbers) followed by a new > line character and then some code to operate on myData. > > 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 ...The NL is only used to break up input: this is saying that what it has seen so far is syntactically incomplete. Is this a standard Unix text file (if you are on Unix)?> ... 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. > > Anyone have any ideas as to what is going on? The reason I am doing this > is to call R from a PERL program.The obvious fix is to put the data in a separate file and use scan(), which will be more efficient (as the input does not need to go through the parser and you do not need to create R's dump format). -- 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._