ncases: Number of Cases in Data

Description Usage Arguments Value See Also Examples

View source: R/quest_functions.R

Description

ncases counts how many cases in a data.frame there are that have a specified frequency of observed values across a set of columns. This function is similar to nrow and is essentially partial.cases + sum. The user can have ncases return the number of complete cases by calling ov.min = 1, prop = TRUE, and inclusive = TRUE (the default).

Usage

1
ncases(data, vrb.nm = names(data), 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.

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

integer vector of length 1 providing the nrow in data with the given amount of observed values.

See Also

partial.cases nrow

Examples

1
2
3
4
5
vrb_nm <- c("Ozone","Solar.R","Wind")
nrow(airquality[vrb_nm]) # number of cases regardless of missing data
sum(complete.cases(airquality[vrb_nm])) # number of complete cases
ncases(data = airquality, vrb.nm = c("Ozone","Solar.R","Wind"),
   ov.min = 2/3) # number of rows with at least 2 of the 3 variables observed

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

Related to ncases in quest...