Re: [R] dataframe of unequal rows

From: Sachin J <sachinj.2006_at_yahoo.com>
Date: Sat 19 Aug 2006 - 03:44:57 EST


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@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.

"The business of the statistician is to catalyze the scientific learning process." - George E. P. Box

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Sachin J
> Sent: Friday, August 18, 2006 9:14 AM
> To: R-help@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@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.
>
                 


        [[alternative HTML version deleted]]



R-help@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. Received on Sat Aug 19 03:59:22 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 19 Aug 2006 - 06:21:30 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.