ncases {quest} | R Documentation |
Number of Cases in Data
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
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 |
ov.min |
minimum frequency of observed values required per row. If
|
prop |
logical vector of length 1 specifying whether |
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 |
Value
integer vector of length 1 providing the nrow in data
with the given amount of observed values.
See Also
Examples
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