So data looks like below. 60000 instances of 93 variables. I want to calculate the number of zeros in the first 4 variables, then the number of zeros in the next 4 variables, ... all the way to the 93rd variable. Currently I have
idx1<-c(1:4)
Z1<-rowSums(Pds[idx1]==0)
To make the above work, I will need to copy and paste 20 times and alter the code for each variable group. Is there an easier way? I will also being doing this for different combinations of variables,i.e., every 3 variables, every 10 variables, every two. I am saving all of these to new variables. If anyone is wondering, I'm doing the Kaggle Otto group challenge for my data mining class final project. As usual, Thanks to everyone who helps.
df= feat_1 feat_2 feat_3 feat_4....
1 0 0 0
0 0 0 0
0 0 0 0
1 0 0 1
0 0 0 0
2 1 0 0
2 0 0 0
. . . .
. . . .
. . . .
. . . .