test.txt:
"V1" "V2" "V3" "V4"
1 2 3 4
5 6 7
8 9
10 11
12 13 14 15
The fields are delimited by tab characters ("\t")
In R:
> read.table(choose.files(),sep='\t',head=TRUE)
V1 V2 V3 V4
1 1 2 3 4
2 5 6 7 NA
3 NA NA 8 9
4 10 NA NA 11
5 12 13 14 15
(I use choose.files() on Windows to select the file via the standard file
browser widget)
-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
"The business of the statistician is to catalyze the scientific learning
process." - George E. P. Box
> -----Original Message-----
> From: Sachin J [mailto:sachinj.2006 at yahoo.com]
> Sent: Friday, August 18, 2006 10:45 AM
> To: Berton Gunter; R-help at stat.math.ethz.ch
> Subject: RE: [R] dataframe of unequal rows
>
> Bert,
>
> I tried readLines. It reads the data as is, but cant access
> individual columns. Still cant figure out how to accomplish
> this. An example would be of great help.
>
> PS: How do you indicate which fields are present in a record
> with less than the
> full number? - Via known delimiters for all fields.
>
> TIA
> Sachin
>
>
> Berton Gunter <gunter.berton at gene.com> wrote:
>
> How do you indicate which fields are present in a
> record with less than the
> full number? Via known delimiters for all fields? Via
> the order of values
> (fields are filled in order and only the last fields in
> a record can
> therefore be missing)?
>
> If the former, see the "sep" parameter in read.table()
> and friends.
> If the latter, one way is to open the file as a
> connection and use
> readLines()(you would check how many values were
> present and fill in the
> NA's as needed).There may be better ways, though.
> ?connections will get you
> started.
>
> -- Bert Gunter
> Genentech Non-Clinical Statistics
> South San Francisco, CA
>
> "The business of the statistician is to catalyze the
> scientific learning
> process." - George E. P. Box
>
>
>
> > -----Original Message-----
> > From: r-help-bounces at stat.math.ethz.ch
> > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf
> Of Sachin J
> > Sent: Friday, August 18, 2006 9:14 AM
> > To: R-help at stat.math.ethz.ch
> > Subject: [R] dataframe of unequal rows
> >
> > Hi,
> >
> > How can I read data of unequal number of observations
> > (rows) as is (i.e. without introducing NA for columns of less
> > observations than the maximum. Example:
> >
> > A B C D
> > 1 10 1 12
> > 2 10 3 12
> > 3 10 4 12
> > 4 10
> > 5 10
> >
> > Thanks in advance.
> >
> > Sachin
> >
> >
> >
> >
> > ---------------------------------
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > 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
> > and provide commented, minimal, self-contained,
> reproducible code.
> >
>
>
>
>
> ________________________________
>
> How low will we go? Check out Yahoo! Messenger's low
> PC-to-Phone call rates.
> <http://us.rd.yahoo.com/mail_us/taglines/postman8/*http://us.r
> d.yahoo.com/evt=39663/*http://voice.yahoo.com>
>