[R] Problem with read.table()
dmcwilli at utk.edu
Mon Apr 15 23:31:29 CEST 2002
I am trying to read machine output data with a 21 row header and 2 row footer.
Numbers of rows and columns are variable. Just skipping the header causes
read.table to choke on the last 2 rows since the number of fields is not the
same as the data table. The header contains information for calculating the
number of rows. I can successfully pick this out and do the calculation, but
cannot get the second read.table() to see the assign the number to "nrows"
(the number is correct; if I enter it manually, the everything works fine).
Currently the function reads all the way to the end and crashes on the footer.
# function to read data with header and footer
grid.layout <- read.table(fname, as.is=T, header=F, sep="\t", comment.char="",
row.ctr <- grid.layout*grid.layout*grid.layout*grid.layout
# tells me I have the right dimensions ...
tmp.df <- read.table(fname, as.is=T, header=T, sep="\t", comment.char="",
skip=20, nrows=row.ctr )
# end function
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