Suppose I have a dataset that contains 100 odd columns, and I only need to store those rows in the data that satisfy one condition that applies to all 100 columns. How to do it?
Suppose it looks like below ... I only need to store rows if any of Col1 or 2 or 3 or 4 columns is> 0
Col1 Col2 Col3 Col4 1 1 3 4 0 0 4 2 4 3 4 3 2 1 0 2 1 2 0 3 0 0 0 0
In the above example, with the exception of the last line, all lines will do this. I need to place the results in the same data file as the original. not sure if I can use lapply to scroll columns where> 0, or I can use a subset. Any help is appreciated
Can I use column indices and do df<-subset(df,c(2:100)>0) . This does not give me the correct result.
source share