Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify docs about NA, NaN, and numeric #1

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/library/base/man/NA.Rd
Expand Up @@ -25,7 +25,8 @@
other atomic vector types which support missing values: all of these
are \link{reserved} words in the \R language.

The generic function \code{is.na} indicates which elements are missing.
The generic function \code{is.na} indicates which elements are missing
(\code{NA}) or (NA) or \sQuote{Not a Number} (\code{link{NaN}}).
avehtari marked this conversation as resolved.
Show resolved Hide resolved

The generic function \code{is.na<-} sets elements to \code{NA}.

Expand Down Expand Up @@ -122,8 +123,11 @@ is.na(x) <- value
on how methods can be tuned to deal with missing values.
}
\examples{
is.na(c(1, NA)) #> FALSE TRUE
is.na(paste(c(1, NA))) #> FALSE FALSE
is.na(c(1, NA, NA_real__, NaN)) #> FALSE TRUE TRUE TRUE
is.na(paste(c(1, NA, NA_real__, NaN))) #> FALSE FALSE FALSE FALSE
avehtari marked this conversation as resolved.
Show resolved Hide resolved

# When NaN should not be considered as missing value
is.na(c(1, NA, NA_real_, NaN)) & !is.nan(c(1, NA, NA_real_, NaN))

(xx <- c(0:4))
is.na(xx) <- c(2, 4)
Expand Down
18 changes: 10 additions & 8 deletions src/library/base/man/is.finite.Rd
Expand Up @@ -18,9 +18,10 @@
and not missing) or infinite.

\code{Inf} and \code{-Inf} are positive and negative infinity
whereas \code{NaN} means \sQuote{Not a Number}. (These apply to numeric
values and real and imaginary parts of complex values but not to
values of integer vectors.) \code{Inf} and \code{NaN} (as well as
whereas \code{NaN} means \sQuote{Not a Number}. \code{Inf} and
\code{NaN} are class of numeric and type of double, and can be
avehtari marked this conversation as resolved.
Show resolved Hide resolved
used in real and imaginary parts of complex values, but not as
values in integer vectors. \code{Inf} and \code{NaN} (as well as
\code{\link{NA}}) are
\link{reserved} words in the \R language.
}
Expand Down Expand Up @@ -85,11 +86,12 @@ NaN
\code{dimnames} and \code{names} attributes are preserved.
}
\seealso{
\code{\link{NA}}, \sQuote{\emph{Not Available}} which is not a number
as well, however usually used for missing values and applies to many
modes, not just numeric and complex.
\code{\link{NA}}, \sQuote{\emph{Not Available}} / \sQuote{Missing value}
which is a a logical constant of length 1 which contains a missing
value indicator. \code{\link{NA}} can be coerced to numeric as
\code{\link{NA_integer_}} and \code{\link{NA_real_}}.
avehtari marked this conversation as resolved.
Show resolved Hide resolved

\code{\link{Arithmetic}}, \code{\link{double}}.
\code{\link{Arithmetic}}, \code{\link{double}}, \code{\link{is.na}}.
}
\references{
The IEC 60559 standard, also known as the
Expand Down Expand Up @@ -117,7 +119,7 @@ NaN
}
\examples{
pi / 0 ## = Inf a non-zero number divided by zero creates infinity
0 / 0 ## = NaN
0 / 0 ## = NaN as defined in IEC 60559 standard

1/0 + 1/0 # Inf
1/0 - 1/0 # NaN
Expand Down
8 changes: 6 additions & 2 deletions src/library/base/man/numeric.Rd
Expand Up @@ -13,7 +13,10 @@
\description{
Creates or coerces objects of type \code{"numeric"}.
\code{is.numeric} is a more general test of an object being
interpretable as numbers.
interpretable as numbers. These include special numeric objects
\code{\link{Inf}}, \code{\link{NaN}}, \code{\link{NA_integer_}},
and \code{\link{NA_real_}}.

}
\usage{
numeric(length = 0)
Expand Down Expand Up @@ -88,7 +91,8 @@ is.numeric(x)
coerces to the class.
}
\seealso{
\code{\link{double}}, \code{\link{integer}}, \code{\link{storage.mode}}.
\code{\link{double}}, \code{\link{integer}}, \code{\link{storage.mode}},
\code{\link{Inf}}, \code{\link{NaN}}.
}
\references{
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
Expand Down