flagged.by: flagged.by

View source: R/flagged.by.R

flagged.byR Documentation

flagged.by

Description

Flag which cells are at or above some threshold.

Usage

flagged.by(x, threshold, or.tied, below, ...)

Arguments

x

Data.frame or matrix of numbers to be compared to threshold value.

threshold

Numeric. The threshold or threshold to which numbers are compared. Default is arithmetic mean of row. Usually one number, but can be a vector of same length as number of rows, in which case each row can use a different threshold.

or.tied

Logical. Default is FALSE, which means we check if number in x is greater than the threshold (>). If TRUE, check if greater than or equal (>=).

below

Logical. Default is FALSE. If TRUE, uses > or >= threshold. If FALSE, uses < or <= threshold.

...

optional additional parameters to pass to analyze.stuff::cols.above.which()

Details

For a matrix with a few cols of related data, find which cells are at/above (or below) some threshold. Returns a logical matrix, with TRUE for each cell that is at/above the threshold. Can be used in EJ analysis as 1st step in identifying places (rows) where some indicator(s) is/are at/above a threshold, threshold value.

Value

Returns a logical matrix the same size as x.

Note

Future work: these functions could have wts, na.rm, & allow cutpoints or benchmarks as a vector (not just 1 number), & have benchnames.

See Also

cols.above.which, another name for the exact same function.

cols.above.count or cols.above.pct to see, for each row, count or fraction of columns with numbers at/above/below threshold.

flagged.only.by to find cells that are the only one in the row that is at/above/below the threshold.

rows.above.count, rows.above.pct, rows.above.which

Examples

out <- flagged.by(x<-data.frame(a=1:10, b=rep(7,10), c=7:16), threshold=7)
x; out # default is or.tied=FALSE
out <- flagged.by(data.frame(a=1:10, b=rep(7,10), c=7:16), threshold=7, or.tied=TRUE, below=TRUE)
out
out <- flagged.by(data.frame(a=1:10, b=rep(7,10), c=7:16) )
# Compares each number in each row to the row's mean.
out

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