miss_filter | R Documentation |
Counts the number of missing values per row and then keeps rows that have at most a chosen number of missing values.
miss_filter(data, missing = 0, reverse = F, by_case = T, vars = NULL)
data |
(data frame) The data. |
missing |
(num) The maximum number of missing values in cases. Defaults to 0 (keep only cases with no missing values). If this is a proportion between 0-1, then it is used as such. |
reverse |
(lgl) Filter based on non-NA data instead. |
set.seed(1)
df = data.frame(ints = 1:10, letters = letters[1:10], unif = runif(10), norm = rnorm(10))
df = miss_add_random(df, prop = .25) %>% mutate(nomiss = T, allmiss = NA)
df
#filter cases/rows
miss_filter(df) #allow no missing values
miss_filter(df, missing = 1) #allow up to 1 value missing
miss_filter(df, missing = 0.5) #allow up to a half missing
#only use certain variables for counting
miss_filter(df, vars = c("ints", "letters"))
#filter columns/vars
miss_filter(df, missing = 0, by_case = F)
miss_filter(df, missing = 0.5, by_case = F)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.