to_na: replace NaN and Inf with NA

Description Usage Arguments Value Note Author(s) Examples

View source: R/conversion.R

Description

Takes out NaN and Inf and replaces them with NA

Usage

1
to_na(x)

Arguments

x

vector

Value

Returns vector with with replaced NAvalues.

Note

— Idea for improvement

Add args to flexible select which scenarios should be set NA

- nan, infinite, other defined values

Author(s)

Daniel Luettgau

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
test <- list(a = c("a", "b", NA),
             b = c(NaN, 1,2, -Inf),
             c = c(TRUE, FALSE, NA))

lapply(test, to_na)

## Output
# $a
# [1] "a" "b" NA

# $b
# [1] NA  1  2 NA

# $c
# [1] TRUE FALSE NA

amit-agni/cutlery documentation built on Dec. 31, 2019, 2:09 p.m.