File: nobs.R

package info (click to toggle)
gdata 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 964 kB
  • sloc: sh: 27; makefile: 15
file content (24 lines) | stat: -rw-r--r-- 584 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## 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, ...)