partial.cases: Find Partial Cases

Description Usage Arguments Value See Also Examples

View source: R/quest_functions.R

Description

partial.cases indicates which cases are at least partially observed, given a specified frequency of observed values across a set of columns. This function builds off complete.cases. While complete.cases requires completely observed cases, partial.cases allows the user to specify the frequency of columns required to be observed. The default arguments are equal to complete.cases.

Usage

1
partial.cases(data, vrb.nm, ov.min = 1, prop = TRUE, inclusive = TRUE)

Arguments

data

data.frame or matrix of data.

vrb.nm

a character vector of colnames from data specifying the variables which will be used to determine the partially observed cases.

ov.min

minimum frequency of observed values required per row. If prop = TRUE, then this is a decimal between 0 and 1. If prop = FALSE, then this is a integer between 0 and length(vrb.nm).

prop

logical vector of length 1 specifying whether ov.min should refer to the proportion of observed values (TRUE) or the count of observed values (FALSE).

inclusive

logical vector of length 1 specifying whether the case should be included if the frequency of observed values in a row is exactly equal to ov.min.

Value

logical vector of length = nrow(data) with names = rownames(data) specifying if the frequency of observed values is greater than (or equal to, if inclusive = TRUE) ov.min.

See Also

complete.cases rowNA ncases

Examples

1
2
3
4
5
6
7
8
9
cases2keep <- partial.cases(data = airquality,
   vrb.nm = c("Ozone","Solar.R","Wind"), ov.min = .66)
airquality2 <- airquality[cases2keep, ] # all cases with 2/3 variables observed
cases2keep <- partial.cases(data = airquality,
   vrb.nm = c("Ozone","Solar.R","Wind"), ov.min = 1, prop = TRUE, inclusive = TRUE)
complete_cases <- complete.cases(airquality)
identical(x = unname(cases2keep),
   y = complete_cases) # partial.cases(ov.min = 1, prop = TRUE,
   # inclusive = TRUE) = complete.cases()

quest documentation built on Sept. 10, 2021, 5:07 p.m.

Related to partial.cases in quest...