R/moreAreValidThan.R
moreAreValidThan.Rd
Helper function to identify rows in x
which have a proportion of
non-missing values (i.e. valid measurements) larger than prop
. Parameter
f
allows to define groups of columns and hence to perform the test
separately in each group. Parameter condiction
allows to combine these
per-group tests to a single logical
value per row, i.e. the default
condition = any
returns TRUE
if in at least one group defined by f
the
proportion of non-missing values is > prop
. With condition = all
more
than prop
non-missing values have to be present in all groups.
moreAreValidThan(x, f = rep(1, ncol(x)), prop = 0.3, condition = any)
x |
|
---|---|
f | optional |
prop |
|
condition | optional |
logical
vector, same length than nrow(x)
, TRUE
for rows that
pass the criteria.
Johannes Rainer
x <- rbind( c(NA, 3, 4, 1, 3, NA, 4, NA), c(4, 2, 3, 4, 5, 5, 2, NA), c(NA, NA, NA, NA, NA, 3, 4, 5)) ## which rows have more than 50% non-missing values moreAreValidThan(x, prop = 0.5)#> [1] TRUE TRUE FALSE## Same but with a grouping of columns moreAreValidThan(x, prop = 0.5, f = c(1, 1, 1, 1, 1, 2, 2, 2))#> [1] TRUE TRUE TRUE## Same, but require it to be true in all groups moreAreValidThan(x, prop = 0.5, f = c(1, 1, 1, 1, 1, 2, 2, 2), condition = all)#> [1] FALSE TRUE FALSE