Data Science Desktop Survival Guide
by Graham Williams |
|||||
Filter Rows Having Missing Values |
20201202 To select the rows from a dataset which have missing values in any of the columns across the dataset we dplyr::filter() dplyr::across() tidyselect::everything() that base::is.na() and reduce it within the dplyr::filter() using the or operator. In the example we randomly sample a few rows and columns to show the result.
ds %>%
filter(across(everything(), is.na) %>% reduce(`|`)) %>% sample_frac() %>% select(date, location, sample(3:length(vars), 4))
|