[R] Reading name-value data
hadley at rice.edu
Fri Jul 29 01:30:34 CEST 2011
Use plyr::rbind.fill? That does match up columns by name.
On Thu, Jul 28, 2011 at 5:23 PM, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
> I have a file of data where each line is a series of name-value pairs, but
> where the names are not necessarily the same from line to line, e.g.
> I would like to create a data frame which lines up the data in the
> corresponding columns. In this case, this would be
> data.frame( a = (1, NA, 4), b = (2, 4, NA), c = (NA, 3, NA), d = (5, NA,
> 1), e = (NA, 3, 1) )
> One way I can think of doing this is to read in the data as one 'long' data
> frame per line with a unique ID, e.g. line one becomes
> then rbind all the lines and use the reshape package function 'cast'.
> Is there a more straightforward way? (I'd have thought rbind would line up
> columns by name, but it doesn't.)
> You received this message because you are subscribed to the Google Groups
> "manipulatr" group.
> To post to this group, send email to manipulatr at googlegroups.com.
> To unsubscribe from this group, send email to
> manipulatr+unsubscribe at googlegroups.com.
> For more options, visit this group at
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
More information about the R-help