I have a big data frame (2628x670316) over 3 GB and want to use the sum function on every row.
The data file looks something like this composed of only 0s, 1s and 2s.
0 1 2 0 0 0 0 0 0 1 1 1 ...
0 1 0 0 0 0 2 2 2 2 2 2 ...
.
.
.
When I run sum(data[1,]==0) this takes ages. Is there a faster way to do it?
Thank you in advance.
PS. The reason I want to use sum is because I want to get the percentage of 0s, 1s and 2s on each row. If there is another way to do that, that answer would also be helpful.