truncate_numeric: Truncate values in a numeric vector, logically or...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/truncate_numeric.R

Description

Takes a numeric vector and returns a vector of equal length, either a logical or a numeric with values truncated within provided ranges.

Usage

1
truncate_numeric(x, lower = -Inf, upper = Inf, type = c("logical", "numeric"))

Arguments

x

numeric vector to be truncated

lower

numeric lower end or allowable range.

upper

numeric upper end or allowable range.

type

character indicating whether to return a "logical" or "numeric" vector.

Value

a vector the same length as the input vector, with either logical or numeric entries.

Author(s)

Bill Forrest forrest@gene.com

See Also

data.frame

Examples

1
2
3
4
5
   dat <- data.frame( x = 0:10, y = rnorm( 11 ), letter = letters[1:11] )
   truncate_numeric( dat$x, 3, 8 ) # logical vector by default
   subset( dat, truncate_numeric( dat$x, 3, 8 ) ) # subset a data frame.
   #
   truncate_numeric( dat$x, 3, 8, 'numeric' ) # numeric vector

wfforrest/maeve documentation built on Jan. 1, 2021, 12:47 p.m.