Here is a simplified version of my dataset:
myDF <- tibble(city = rep(c("London", "Madrid", "Paris"), each = 3),
date = rep(c("Day1", "Day2", "Day3"), times = 3),
visits = c(20, 32, NA, NA, 28, 26, 25, NA, 21))
# A tibble: 9 x 3
city date visits
<chr> <chr> <dbl>
1 London Day1 20
2 London Day2 32
3 London Day3 NA
4 Madrid Day1 NA
5 Madrid Day2 28
6 Madrid Day3 26
7 Paris Day1 25
8 Paris Day2 NA
9 Paris Day3 21
I know I can find the index for each row which has NA in the "visits" column with the following:
which(is.na(myDF$visits))
# console output: 3, 4, 8
But if the above code returns hundreds of index values, how can I create a new dataset which only contains the rows that appear in the console output?
If there is alternative code that can be used please mention.
Any help is much appreciated :)