[R] More info - S-Plus compatability
Neil Shephard
mdeasnds at fs1.ser.man.ac.uk
Fri Jan 17 13:39:03 CET 2003
Dear all,
Thanks to those of you who have replied, the majority of the
comments pointed out that the error caused by scan may originate
from another function, and closer inspection of the output from
traceback() reveals that it is in fact the read.table function where
the error is originating from the full output of which I have included
below.
The error msg I recieve is
Error in scan(file = file, what = what, sep = sep, quote = quote, dec
= dec, :
line 1 did not have 2 elements
Execution halted.
traceback()
8: scan(file=file, what=what, sep = sep, quote = quote, dec = dec,
nmax = nrows, skip =0, na.strings, quiet = TRUE, fill = fill,
strip.white = strip.white, nlak.lines.skip = blank.lines.skip,
multi.line = FLASE, comment.char = comment.char)
7: read.table("_data\\TempFile, sep = ",", col.names = c("pair1",
"pair2"))
6:ReadIBD.data("ibd.out")
5:RunGH(dat)
4:Read.Data(dat, x, HRallele)
3:eval.with.vis(expr, envir, enclos)
2:eval.with.vis(ei, envir)
1:source("TrendTest.Main.SSC")
grep -e 'read.table; *.SSC
indicates that the read.table() function is called in ReadIBD.SSC on
lines seven and twelve, and that the error is occuring with the
second read.table() where the file '_Data\\TempFile' is being read
(see copy of ReadIBD.data.SSC below).
ReadIBD.data_function(file) {
### Funtion to read the IBD probability data from GENEHUNTER
### This data was generated from using "Dump IBD" command in
GENEHUNTER
### File = ibd.out file from genehunter
temp_read.table(file, skip=1, col.names=c("pos","pedid", "pair",
"prior.c0", "prior.c1", "prior.c2", "post.c0", "post.c1",
"post.c2"),
row.names=NULL)
write.table(temp$pair,file="_Data\\TempFile")
pairTemp_read.table("_Data\\TempFile", sep=",",
col.names=c("pair1","pair2"))
ibd_cbind.data.frame(temp,pairTemp)
return(ibd)
}
Whilst not overly familiar with R/S-Plus syntax there are a couple
of things I've noticed, firstly the second file that is trying to be read
(where the error occurs) is actually called '_Data\TempFile' instead
of '_Data\\TempFile'. Secondly the columns do not appear to be
seperated by "," as indicated in the read.table() statement, the
numbers are encapsulated by "" and are seperated by blank space
as shown in the sample below.
"x"
"1" "1,2"
"2" "1,3"
"3" "1,4"
..
..
I now have the problem of trying to workout why the "x" occurs on
the first row (as this is clearly where the error is occuring as the
Error statement indicates "line 1 did not have 2 elements").
grep -e '_Data' *.SSC
reveals that the _Data\\TempFile is created on the previous line of
ReadIBD.Data.SSC after having read the file 'ibd.out'. So I'm not
sure why the first line is being created with "x" on the first line as
the 'ibd.out' file is the correct format (I checked this visually). It
may be a problem with the way in which the 'ibd.out' file is being
read by R that is causing this, but I'm not sure.
Can anyone see any potential problems with the read.table() and
write.table() functions in the above script file???
Thanks again to all who offered help, and in anticipation of
responses to this msg,
Regards
Neil
Neil Shephard
Genetics Statistician
ARC Epidemiology Unit, University of Manchester
neil.shephard at man.ac.uk
neil.shephard at mindless.com
"Contrariwise, if it was so, it might be; and if it
were so it would be; but as it isn't, it ain't. That's
logic" - Tweedledee (Alice Through the Looking Glass)
More information about the R-help
mailing list