[R] Fwd: Counting number of values by row (text, not numbers)
Laura Ferrero-Miliani
laurafe at gmail.com
Fri Apr 16 13:18:06 CEST 2010
Hi everyone!
I am very new to R and I am having some difficulties.
My data set looks something like this:
subject A B C
D E
1 cat monkey cat
dog cat
2 cat cat cat
cat dog
....
I want to create three new variables, that count the amount of "cat",
"monkey" and "dog" per subject
subject A B C
D E cat dog monkey
1 cat monkey cat
dog cat 3 1 1
2 cat cat cat
cat dog 4 1 0
....
I have been looking at rowSums, rowsum, apply, grep, and doing some
searches, but I can only find count for numerical values or NA values.
Thanks in advance,
L
More information about the R-help
mailing list