Deleting rows based on what they contain

Hi everyone! I'm new to R and have a quick question about deleting rows :slight_smile: I have a data set with multiple columns and multiple rows. I want to strip out rows where the "Depth" column contains "Integrated" or "Air", so I did that with...

my_data_inflow <- filter(my_data_inflow, ! Depth..m. %in% c("Integrated","Air") )

However, this simply enters NA for these rows. Is there a way to delete the rows with this condition? Thank you so much in advance to anyone who is able to provide any suggestions!

Have a great day!

Can you please share a small part of the data set in a copy-paste friendly format?

In case you don't know how to do it, there are many options, which include:

  1. If you have stored the data set in some R object, dput function is very handy.

  2. In case the data set is in a spreadsheet, check out the datapasta package. Take a look at this link.

Sure! Do you mean like this? Here, rows 5 and 6 are what I want to delete. I was hoping to find a way to delete them based on the fact that the "Depth" column contains "NA" for each. Let me know if this isn't what you meant by pasting a small part of the data set, and I can certainly try something else.

    Date   Site

1 2013-04-15 Inflow
2 2013-04-15 Inflow
3 2013-04-15 Inflow
4 2013-04-15 Inflow
5
6
Depth..m. Light..uE.m2.s. Temp..C..
1 0.0 1059 13.5
2 0.5 258 13.1
3 1.0 108 13.0
4 1.5 29 12.7
5 NA NA NA
6 NA NA NA

Sure! Is this what you mean by paste a small part of the data? R has entered "NA" for Date, Depth, Light, and Temp because I had it strip out those rows. However, I want to permanatley delete these rows, preferably using the fact that the Depth column has NA entered. If this isn't what you meant by pasting a bit of the data please let me know and I can try something else! Thank you!

Date Site
1 2013-04-15 Inflow
2 2013-04-15 Inflow
3 2013-04-15 Inflow
4 2013-04-15 Inflow
5
6
Depth. Light Temp
1 0.0 1059 13.5
2 0.5 258 13.1
3 1.0 108 13.0
4 1.5 29 12.7
5 NA NA NA
6 NA NA NA

That is not copy/paste friendly, please use one of the two methods mentioned on my previous post.