Laura Ferrero-Miliani
2010-Apr-16 11:08 UTC
[R] Counting number of values by row (text, not numbers)
Hi everyone! I am very new to R and I am having some difficulties. My data set looks something like this: A B C D E cat monkey cat dog cat cat
Laura Ferrero-Miliani
2010-Apr-16 11:18 UTC
[R] Fwd: Counting number of values by row (text, not numbers)
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