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.