indicator: indicator function of an interval in the real line

Description Usage Arguments Value Author(s) Examples

View source: R/indicator.R

Description

indicator function of an interval in the real line

Usage

1
indicator(x, min = -Inf, max = Inf, liq = ">=", riq = "<=")

Arguments

x

numeric vector of values to be tested.

min

numeric, scalar lower bound. -Inf is a valid value.

max

numeric, scalar upper bound. Inf is a valid value.

liq

character. Left inequality. ">" or ">=".

riq

characher. Right inequality. "<" or "<=".

Value

a logical vector with TRUE when x[i] is in the interval given by the parameters of this function. Logical values were used for memory efficiency when large scale usage of this function.

Author(s)

Francisco Mendoza-Torres (mentofran@gmail.com)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
xe <- c(-Inf, -3, 2, 6, Inf)
1 * indicator(x = xe, min = 2, max = 6, liq = ">=", riq = "<=")
    indicator(x = xe, min = 2, max = 6, liq = ">=", riq = "<=")
indicator(x = xe, min = 2, max = 6, liq = ">" , riq = "<=")
indicator(x = xe, min = 2, max = Inf, liq = ">=", riq = "<")
indicator(x = xe, min = 2, max = Inf, liq = ">=", riq = "<=")

# Also works in the case that x is unique and min and max are vectors
xl <- c(-1, 0.3, -4)
xu <- c( 1,   1, -2)
indicator(0, xl, xu)

mathphysmx/percolation documentation built on Aug. 14, 2019, 2:03 a.m.