count_if: Increments a counter when the criteria is met

View source: R/transforms_time.R

count_ifR Documentation

Increments a counter when the criteria is met

Description

Increments a counter when the criteria is met

Usage

count_if(criteria, fill.na = T)

Arguments

criteria

A logical expression that is TRUE when the count should increment

fill.na

TRUE if NA values in criteria should be filled with FALSE or FALSE to leave them as NA.

Value

A vector with the running count of times the criteria has been met.

Examples

EVID=c(1,1,0,0,1,1,1,0)
CMT= c(1,2,1,2,1,2,NA,2)
count_if(EVID==1 & CMT==1)
count_if(EVID==1 & CMT==1, fill.na=FALSE)

qPharmetra/PMDatR documentation built on April 7, 2024, 5:42 p.m.