I believe the regularity of the problem allows a (to me, anyway) simpler procedure.
td <- t(apply(d,2, na.omit)) data.frame(split(as.numeric(td[,-1]),td[,1])) -- Bert On Sat, Apr 28, 2012 at 9:33 AM, Rui Barradas <ruipbarra...@sapo.pt> wrote: > Hello, > > This solution is not very pretty but it works. > > nms <- unlist(d[1, ]) > nm <- unique(nms) > dd <- na.exclude(sapply(nm, function(jj){ > inx <- nms %in% jj > do.call(rbind, as.list(d[, inx])) > })) > dd <- dd[ dd[ , nm[1]] != nm[1], ] > dd <- data.frame(apply(dd, 2, as.integer)) > dd > > Hope this helps, > > Rui Barradas > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Consolidate-column-contents-of-equally-named-columns-tp4594852p4594980.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm ______________________________________________ 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.