this function takes a subset of a dataset, omitting all cases with missings in variables specified in 'keep' and omitting all variables that still have missings after that. Good to see how large your dataset for a certain analysis will be and which covariates are 'free' in terms of sample size.

take_nonmissing(df, keep = c())

Arguments

df

dataset

keep

defaults to empty vector

Examples

data(ChickWeight) ChickWeight[1:2,c('weight','Chick')] = NA ChickWeight[3:4,'Diet'] = NA names(ChickWeight); nrow(ChickWeight)
#> [1] "weight" "Time" "Chick" "Diet"
#> [1] 578
ChickWeight2 = take_nonmissing(ChickWeight, keep = c('weight')) names(ChickWeight2); nrow(ChickWeight2)
#> [1] "weight" "Time" "Chick"
#> [1] 576