# erase rows with zero values in R

#### IoannaChr

##### New Member
I have a dataframe and I since some rows have zero values I would like to omit them. I now that for NA values we have na.omit so I am looking for something similar for zero values.

Last edited:

#### Navaak

##### Member
I am not aware of a function that directly does that, but you could try the following. Let's suppose your data.frame is x:

Code:
ind <- which(apply(x,1,is.element, el=0))
x <- x[-ind,]
The object ind contains the rows that have at least one zero. Then, with a logical indexing you can omit these rows. Hope this helps!

#### IoannaChr

##### New Member
I am not aware of a function that directly does that, but you could try the following. Let's suppose your data.frame is x:

Code:
ind <- which(apply(x,1,is.element, el=0))
x <- x[-ind,]
The object ind contains the rows that have at least one zero. Then, with a logical indexing you can omit these rows. Hope this helps!
Thank you very much!