flagged: Which rows have a value above threshold in at least one...

View source: R/flagged.R

flaggedR Documentation

Which rows have a value above threshold in at least one column

Description

Flags rows that have values above some threshold in at least one column.

Usage

flagged(df, threshold = 0.8, or.tied = TRUE)

Arguments

df

Data.frame with numeric values to be checked against the threshold.

threshold

Number that is the threshold that must be (met or) exceeded for a row to be flagged. Optional, default is 0.80

or.tied

Logical, optional, default is TRUE, in which case a value equal to the threshold also flags the row.

Details

The use of na.rm=TRUE in this function means it will always ignore NA values in a given place and take the max of the valid (non-NA) values instead of returning NA when there is an NA in that row

Value

Returns a logical vector or data.frame the shape of df

Examples

set.seed(999)
places <- data.frame(p1=runif(10, 0,1), p2=c(NA, runif(9,0,1)), p3=runif(10,0,1))
pctilecols <- c('p1','p2', 'p3')
x <- flagged(places[ , pctilecols], 0.80)
a <- cbind(any.over.0.8=x, round(places,2))
a[order(a[,1]),]

ejanalysis/ejanalysis documentation built on April 2, 2024, 10:12 a.m.