File: replace_nan_inf.Rd

package info (click to toggle)
r-cran-datawizard 1.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,300 kB
  • sloc: sh: 13; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 748 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/replace_nan_inf.R
\name{replace_nan_inf}
\alias{replace_nan_inf}
\title{Convert infinite or \code{NaN} values into \code{NA}}
\usage{
replace_nan_inf(x, ...)
}
\arguments{
\item{x}{A vector or a dataframe}

\item{...}{Currently not used.}
}
\value{
Data with \code{Inf}, \code{-Inf}, and \code{NaN} converted to \code{NA}.
}
\description{
Replaces all infinite (\code{Inf} and \code{-Inf}) or \code{NaN} values with \code{NA}.
}
\examples{
# a vector
x <- c(1, 2, NA, 3, NaN, 4, NA, 5, Inf, -Inf, 6, 7)
replace_nan_inf(x)

# a data frame
df <- data.frame(
  x = c(1, NA, 5, Inf, 2, NA),
  y = c(3, NaN, 4, -Inf, 6, 7),
  stringsAsFactors = FALSE
)
replace_nan_inf(df)
}