Dear Members,

is there a better solution to count the amounts of occurrence in a row with string data than with loops to get the count data.frame?

test =data.frame("first"=c("seven","two","five","four"),
                 "second"=c("three","one","three","one"),
                 "third"=c("four","two","three","four"),
                 "fourth"=c("four","one","one","four"))



count =data.frame("double1"=c("four","two","three","NA"),
                 "double2"=c("NA","one","NA","NA"),
                 "triple"=c("NA","NA","NA","one"))


double1: first double occurrence in row  (NA if triple available)
double2: second double occurrence in row (NA if triple available or if there is only one double)
triple: triple occurrence in row (NA if a double available)


Kind regards Knut

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to