truncare: Truncate or censor vectors

Description Usage Arguments Details Value Examples

View source: R/truncare.R

Description

truncare will truncate a vector with replacing elements greater or less than given bounds with replacement values (missing by default). censor is a special case that uses the upper and bound values as the replacements.

Usage

1
2
3
4
truncare(x, left = -Inf, right = Inf, newleft = NA, newright = NA,
  leq = FALSE, geq = FALSE)

censor(x, left = -Inf, right = Inf)

Arguments

x

A vector

left, right

Boundary values for truncation

newleft, newright

Value to replace truncated elements

leq, geq

If TRUE use <= (>=) for tests at the boundary, otherwise use < (>).

Details

The more intuitive name truncate was not chosen, because a base function truncate already has that name. Truncare is the Latin origin of truncate.

Value

Vector of the same size as x, with truncated elements replaced.

Examples

1
2
truncare(1:10, left = 2, right = 5)
censor(-5:5, 0, 4)

jrnold/rubbish documentation built on May 20, 2019, 2:05 a.m.