[R] dataframe of unequal rows

Berton Gunter gunter.berton at gene.com
Fri Aug 18 18:34:01 CEST 2006


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



More information about the R-help mailing list