nobs {gdata}R Documentation

Compute the Number of Non-missing Observations

Description

Compute the number of non-missing observations. Special methods exist for data frames, and lm objects.

Usage

nobs(x, ...)
## Default S3 method:
nobs(x, ...)
## S3 method for class 'data.frame':
nobs(x, ...)
## S3 method for class 'lm':
nobs(x, ...)

Arguments

x Target Object
... Optional parameters (currently ignored)

Details

In the simplest case, this is really just wrapper code for sum(!is.na(x)).

Value

A single numeric value or a vector of values (for data.frames) giving the number of non-missing values.

Author(s)

Gregory R. Warnes gregory_r_warnes@groton.pfizer.com

See Also

is.na, length

Examples


x <- c(1,2,3,5,NA,6,7,1,NA )
length(x)
nobs(x)

df <- data.frame(x=rnorm(100), y=rnorm(100))
df[1,1] <- NA
df[1,2] <- NA
df[2,1] <- NA

nobs(df)

[Package gdata version 2.0.6 Index]