rationalize | R Documentation |
rationalize
transforms all numeric elements to be rational values or NA,
thus removes all NaN,Inf
and replaces them with NA
.Only allow rational values in numeric vectors
rationalize
transforms all numeric elements to be rational values or NA,
thus removes all NaN,Inf
and replaces them with NA
.
rationalize(.x, ...)
## Default S3 method:
rationalize(.x, ...)
## S3 method for class 'numeric'
rationalize(.x, ...)
## S3 method for class 'data.frame'
rationalize(.x, ...)
.x |
vector or data.frame |
... |
columns to be evaluated. Only applicable if .x is a data frame. |
#' If a non-numeric vector is passed, it is unchanged. If a data.frame is passed, it evaluates all columns separately.
For vectors: same data type/class as .x.
For data.frame: a tbl data frame.
NULL
NULL
NULL
s
, rationalize
, vignette("s")
, vignette("hablar")
x <- c(3, -Inf, 6.56, 9.3, NaN, 5, -Inf)
rationalize(x)
df <- data.frame(num_col = c(Inf, 3, NaN),
chr_col = c("a", "b", "c"),
stringsAsFactors = FALSE)
df
rationalize(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.