R/nobs.R

Defines functions n_obs nobs.data.frame nobs.default nobs

Documented in nobs n_obs nobs.data.frame nobs.default

## Redefine here, so that the locally defined methods (particularly
## nobs.default) take precedence over the ones now defined in the
## stats package

nobs <- function(object, ...)
  UseMethod("nobs")

nobs.default <- function(object, ...)
{
  if(is.numeric(object) || is.logical(object))
    sum(!is.na(object))
  else
    stats::nobs(object, ...)
}


nobs.data.frame <- function(object, ...)
  sapply(object, nobs.default)

## Now provided by 'stats' package, so provide alias to satisfy
## dependencies
nobs.lm <- stats:::nobs.lm

n_obs <- function(object, ...) nobs(object, ...)
warnes/gdata documentation built on Dec. 5, 2023, 12:20 a.m.