-1

I have an excel file that I have imported into R and set up a data frame. I am trying to filter the data so that any cell that has NA in as specific column the row is removed with in the data frame. Tried a couple of different things that do not seem to be working

I have tried using filter and dplyr but they either create a new data frame or remove the rest of the data which is not what I want

  • 1
    what have you tried? please share your code and data so we can help. you can use `dput(yourdata)` to share your data – Mike Jul 07 '23 at 17:10
  • 1
    Please read about [how to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and update your question accordingly. Include a sample of your data by pasting the output of `dput()` into your post or `dput(head())` if you have a large data frame. Also include code you have tried, any relevant errors, and expected output. If you cannot post your data, then please post code for creating representative data. – LMc Jul 07 '23 at 17:14
  • colnames (SA[,20]) = "2000" SA <- subset(SA,!is.na(2000)) I am trying this but it is not removing the row – Corrin Merry Jul 07 '23 at 17:19

1 Answers1

0

The most simple solution would be something like this.

d <- data.frame(id=1:10, value=c(1, 4, NA, 3, 7, NA, 9, 7, NA, NA))
d <- d[d$value != NA,]

However we can't be more specific/helpful if you don't provide an example code...

Michael Marx
  • 104
  • 8