Use plyr::rbind.fill? That does match up columns by name. Hadley On Thu, Jul 28, 2011 at 5:23 PM, Stavros Macrakis <macra...@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. > a=1,b=2,d=5 > b=4,c=3,e=3 > a=5,d=1 > 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 > cbind(id=1,data.frame(variable=c('a','b','d'),value=c(1,2,5))) > 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.) > -s > > -- > You received this message because you are subscribed to the Google Groups > "manipulatr" group. > To post to this group, send email to manipul...@googlegroups.com. > To unsubscribe from this group, send email to > manipulatr+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/manipulatr?hl=en. >
-- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ ______________________________________________ R-help@r-project.org 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.