Learn R Programming

MQMF (version 0.1.1)

countgtzero: countgtzero used in apply to count numbers > zero in a vector

Description

countgtzero used in the base function 'apply', or 'tapply' to count how many numbers are greater than zero in a vector

Usage

countgtzero(invect)

Arguments

invect

vector of values

Value

An integer counting how many numbers are > 0

Examples

Run this code
# NOT RUN {
x <- matrix(trunc(runif(20)*10),nrow=4,ncol=5)
print(x)
apply(x,1,countgtzero) # count by rows
apply(x,2,countgtzero) # count by columns
# }

Run the code above in your browser using DataLab