countones {MQMF}R Documentation

countones used in apply to count the number of ones in a vector

Description

countones used in the base function 'apply', or 'tapply' to count the number of ones in a vector

Usage

countones(invect)

Arguments

invect

vector of values

Value

A single value of zero or the number of ones

Examples

x <- matrix(trunc(runif(20)*10),nrow=4,ncol=5)
print(x)
apply(x,1,countones)  # by rows

[Package MQMF version 0.1.5 Index]