[R] Consolidate column contents of equally "named" columns
Rui Barradas
ruipbarradas at sapo.pt
Sat Apr 28 18:33:12 CEST 2012
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.
More information about the R-help
mailing list