[R] counting similar strings in data.frame
Knut Krueger
rh at knut-krueger.de
Fri Jun 26 10:09:42 CEST 2015
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
More information about the R-help
mailing list