
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
.
partial.cases(data, vrb.nm, ov.min = 1, prop = TRUE, inclusive = TRUE)
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
.
data.frame or matrix of data.
a character vector of colnames from data
specifying the
variables which will be used to determine the partially observed cases.
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)
.
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).
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
.
complete.cases
rowNA
ncases
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()
Run the code above in your browser using DataLab