[R] Setting the Number of Columns
Jonathan Baron
baron at cattell.psych.upenn.edu
Wed May 29 18:07:14 CEST 2002
On 05/29/02 15:19, Matt Borkowski wrote:
>I am trying to read in a data set with 17 columns into a data frame. The
>problem is, there are some lines in the data that occasionally pop up with
>less than 17 numbers in a row. I was trying to use the command
>
>data <- read.table("dataset.dat", fill=TRUE, quote = "")
>
>There was no problem running this with an older version of R and the data
>was forced into a data frame with 17 columns with the missing data filled in
>as NA. But after updating to the newest version something changed and now
>the data is being forced into a data frame with only 14 columns.
I had this problem once. I solved it by moving one of the long
lines of data to the beginning of the file, so it was the first
record. Apparently R decided to get the number of columns from
the first record. I just tried this with R 1.5.0 and it still
works. If necessary you can make up a dummy line and delete it.
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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