> mm1 <- cast(mm, Class~Name) > aba <- mm1[,2:6] > aba[is.na(aba)] <- 1 > final <- data.frame(mm1$Class, aba) > names(final) <- names(mm1) > final
You can abbreviate all this to: final <- cast(mm, Class ~ Name, fill = 1) Hadley -- http://had.co.nz/ ______________________________________________ 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.