CountValue counts the number positive occurrences of a specified value in a vector X.

CountValue(X, VALUE)

Arguments

X

vector possibly containing NAs

VALUE

specified value to be counted. VALUE=NA work.

Value

number of components == VALUE

Details

CountValue

Examples

if (FALSE) { CountValue(c(1,2,NA,NA,5), NA) CountValue(c(1,2,2,2,NA,5), VALUE=2) ## Typical application df<-matrix(sample(LETTERS[1:5], 50, replace=T), ncol=10) df apply(df,1,CountValue,"A") apply(df,2,CountValue,"A") }