I have the following test df:
df <- data.frame(Block = c('1' , '1' , '1' , '2' , '2' , '2' , '3' , '3' , '3') ,
A = c('1' , '0' , '0', '4' , '0', '0' , '1' , '0' , '0') ,
B = c('0' , '1' , '0' , '0' , '4' , '0', '0', '6' , '0') ,
C = c('0' , '0' , '1' , '0' , '0' , '4' , '0' , '0' , '5'))
I'd like to remove the unnecessary 0's so that the A, B, and C only have values >0.
The output would be:
df1 <- data.frame(Block = c('1' , '2' , '3') ,
A = c('1' , '4' , '1') ,
B = c('1' , '4' , '6') ,
C = c('1' , '4' , '5'))