I feel this is a very easy thing but I've never done it before and it is
getting frustrating.
I have a big data.frame (1445846 rows, 15 col)
that looks like this:
V1 V2 V3 V4 V5
1 home sister brother chair 0
2 cat dog animal 0 0
3 girl boy 0 0 0
4 knife fork spoon 0 0
and I want to count how many values different from 0 are in each row, and
get the output count in a vector that is as long as length(MyTable). For the
above example it would be c (4,3,2,3).
I've tried sum (MyTable != "0") but it gives the total amount of values
different from 0 in all the data.frame.
And sum(MyTable [1,] != "0") obviously gives only the first row, even if I
repeat it throughout all length(MyTable).
How does that work?
Thank you,
a newbie.
--
View this message in context:
http://r.789695.n4.nabble.com/frequency-count-by-row-tp4450553p4450553.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
[email protected] 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.