Description Usage Arguments Value Author(s) See Also Examples
View source: R/truncate_numeric.R
Takes a numeric vector and returns a vector of equal length, either a logical or a numeric with values truncated within provided ranges.
1 | truncate_numeric(x, lower = -Inf, upper = Inf, type = c("logical", "numeric"))
|
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. |
a vector the same length as the input vector, with either logical or numeric entries.
Bill Forrest forrest@gene.com
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.