[R] Choose between duplicated rows
francy
francy.casalino at gmail.com
Sun Apr 15 22:08:58 CEST 2012
I also tried using Jim's code, but it doesn't work as expected with my real
dataset. This is what I did:
Best.na <- do.call(rbind, lapply(split(x, x$A), function(.grp){
best <- which.min(apply(.grp, 1, function(a) sum(is.na(a))))
.grp[best, ]
}))
df.split <- split(Best.na, Best.na$id)
Best.date <- lapply(df.split, function(x){
# Select by given criterion
y <- x[which(max(x$A) == x$A),]
y
})
Best.date <- do.call(rbind, Best.date)
Thank you again for your help.
--
View this message in context: http://r.789695.n4.nabble.com/Choose-between-duplicated-rows-tp4557833p4559792.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list