Karl Ove Hufthammer wrote:
In article <4addc1d0.2040...@yahoo.de>, niederlein-rs...@yahoo.de
says...
In every list entry is a data.frame but the columns are only partially
the same. If I have exactly the same columns, I could do the following
command to combine my data:
do.call("rbind", myList)
but of course it does not work with differnt column names. Is there any
easy way to retrieve a combined table like this:
You're in luck. 'rbind.fill' in the 'plyr' package does exactly what you
want.
Thanks a lot for your hint. I'll give it a look :-)
So far, I have solved it with basic tools like this (it's less work than
I thought):
availableColumns <- unique(unlist(sapply(myList, names)))
myList <- lapply(myList, FUN = function(entry) {
missingColumns <- availableColumns[which(!availableColumns %in%
names(entry))]
entry[, missingColumns] <- NA
entry
})
do.call("rbind", myList)
______________________________________________
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.