I have a problem to solve how to remove rows with a Zero value in R. In others hand, I can use na.omit()
to delete all the NA values or use complete.cases
You can use filter from dplyr package.
Let's call your data frame df
library(dplyr)
df1 <- filter(df, Mac1 > 0, Mac2 > 0, Mac3 > 0, Mac4 > 0)
df1 will have only rows with entries above zero. Hope this helps.
I prefer a simple adaptation of csgillespie's method, foregoing the need of a function definition:
d[apply(d!=0, 1, all),]
where d
is your data frame.