markleeds at verizon.net
2006-Jun-04 00:06 UTC
[R] difference in behavior between batch and source
Hi : I am using R 2.20 on windows XP and I have a REALLY long read.table statement because the col.names argument has 440 character strings in it. ( I use python to write R code ). When I run the read.table statement inside an R program ( the R program only consists of the read.table statement ) using the source command in an interactive R session, everything works fine. But, if I take the same program and try to run it using R CMD BATCH program name , the .Rout file shows me that the execution gets halted at one of the col.names arguments but there is no error message. it just says "execution halted". So, I am thinking that this may have to do with some limit in R for how long the col.names argument can be ( or any command for that matter ) ? But, the same program works using the source command and I would think that the source command still has to read theline in somewhere ? What makes me think even more that the problem has something to do with the length of the command is that, as a test, I took the tread.table command and copied and pasted it into an interactive session to see if it would run that way. What was interesting was that the whole command did not get pasted and the pasting stopped at exactly the same place that the .Rout file showed that it stopped during BATCH mode. I can't send the command right now because I don't have email at the location where I am working but I may be able to send it later ? Any thoughts, suggestions or solutions would be really appreciated because I need to be able to get this program to work using BATCH mode. Thanks a lot.
Gabor Grothendieck
2006-Jun-04 00:15 UTC
[R] difference in behavior between batch and source
Maybe: nm <- c("a", "b", "c") nm <- c(nm, "d", "e", "f") ... read.table("myfile.dat", col.names = nm) or paste the column names into the first line of the data file using a text editor and use: read.table("myfile.dat", header = TRUE) On 6/3/06, markleeds at verizon.net <markleeds at verizon.net> wrote:> Hi : I am using R 2.20 on windows XP and I have a REALLY > long read.table statement because the col.names argument > has 440 character strings in it. ( I use python to write R code ). > When I run the read.table statement inside an R program > ( the R program only consists of the read.table statement ) > using the source command in an interactive R session, > everything works fine. But, if I take the same program > and try to run it using R CMD BATCH program name , > the .Rout file shows me that the execution gets halted at > one of the col.names arguments but there is no error message. > it just says "execution halted". > > So, I am thinking that this may have to do with some limit > in R for how long the col.names argument can be ( or > any command for that matter ) ? But, the same program works using the source command and I would think that the source command > still has to read theline in somewhere ? > > What makes me think even more that the problem has something to > do with the length of the command is that, as a test, > I took the tread.table command and copied and pasted it into > an interactive session to see if it would run that way. > What was interesting was that the whole command did not get pasted and the pasting stopped at exactly the same place that the .Rout file showed that it stopped during BATCH mode. > > I can't send the command right now because I don't have email at > the location where I am working but I may be able > to send it later ? Any thoughts, suggestions or solutions > would be really appreciated because I need to be able > to get this program to work using BATCH mode. > > Thanks a lot. > > ______________________________________________ > 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 >
Prof Brian Ripley
2006-Jun-04 06:39 UTC
[R] difference in behavior between batch and source
There is a documented limit of 1000 bytes on R input lines. You are probably hitting it. Try teaching your Python code generator to wrap lines. NB: input means input from the console or stdin, not to the parser. The front-end is asked for a line of up to 1000 bytes. Some front-ends may supply a longer line, but Rterm.exe will not. On Sat, 3 Jun 2006, markleeds at verizon.net wrote:> Hi : I am using R 2.20 on windows XP and I have a REALLY > long read.table statement because the col.names argument > has 440 character strings in it. ( I use python to write R code ). > When I run the read.table statement inside an R program > ( the R program only consists of the read.table statement ) > using the source command in an interactive R session, > everything works fine. But, if I take the same program > and try to run it using R CMD BATCH program name , > the .Rout file shows me that the execution gets halted at > one of the col.names arguments but there is no error message. > it just says "execution halted".Syntax errors in batch can do that for you.> So, I am thinking that this may have to do with some limit > in R for how long the col.names argument can be ( or > any command for that matter ) ? But, the same program works using the source command and I would think that the source command > still has to read theline in somewhere ? > > What makes me think even more that the problem has something to > do with the length of the command is that, as a test, > I took the tread.table command and copied and pasted it into > an interactive session to see if it would run that way. > What was interesting was that the whole command did not get pasted and the pasting stopped at exactly the same place that the .Rout file showed that it stopped during BATCH mode. > > I can't send the command right now because I don't have email at > the location where I am working but I may be able > to send it later ? Any thoughts, suggestions or solutions > would be really appreciated because I need to be able > to get this program to work using BATCH mode. > > Thanks a lot. > > ______________________________________________ > 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 >-- 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