oob: Replace values below or above a threshold (or bound) with new...

oobR Documentation

Replace values below or above a threshold (or bound) with new values

Description

Replace values below or above a threshold (or bound) with new values

Usage

squash_into_low_high(
  x,
  val_low = 0,
  val_low_replace = val_low,
  val_high = 1,
  val_high_replace = val_high
)

cut0Inf(x, val = NA)

finite01(x, val_low_replace = 0, val_high_replace = 1)

Arguments

x

A vector.

val_low

A value. The lower threshold (or bound).

val_low_replace

A value. The replacement for values in x below val_low.

val_high

A value. The upper threshold (or bound).

val_high_replace

A value. The replacement for values in x below val_low.

val

A value. The replacement value.

Examples

x <- seq(-5, 5)
squash_into_low_high(x)
squash_into_low_high(x, val_low = 0, val_high = 3)
squash_into_low_high(
  x,
  val_low = 0, val_low_replace = -999,
  val_high = 3, val_high_replace = 999
)

cut0Inf(c(-5, 0, NA, 0.5, 1, 2, Inf))

finite01(c(-5, 0, NA, 0.5, 1, 2, Inf))


DrylandEcology/rSW2utils documentation built on Dec. 9, 2023, 10:44 p.m.