nobs {gregmisc} | R Documentation |
Compute the number of non-missing observations. Special methods exist for data frames, and lm objects.
nobs(x, ...) ## Default S3 method: nobs(x, ...) ## S3 method for class 'data.frame': nobs(x, ...) ## S3 method for class 'lm': nobs(x, ...)
x |
Target Object |
... |
Optional parameters (currently ignored) |
In the simplest case, this is really just wrapper code for
sum(!is.na(x))
.
A single numeric value or a vector of values (for data.frames) giving the number of non-missing values.
Gregory R. Warnes gregory_r_warnes@groton.pfizer.com
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)