Placeholder for NaNs

This commit is contained in:
Hadley Wickham 2022-04-29 15:01:54 -05:00
parent e3383627f5
commit ecc95b3145
1 changed files with 27 additions and 0 deletions

View File

@ -221,6 +221,7 @@ health |>
Summary functions generally work with zero-length vectors, but they may return results that are surprising at first glance.
There's almost always some deeper logic behind them.
A sometimes simpler approach is to perform the summary and then make the implicit missings explicit with `complete()`.
```{r}
@ -237,3 +238,29 @@ health |>
```
Main con of this approach is that you need to carefully specify the `fill` argument so that
## NaN
Special not a number.
In general it behaves like an `NA`:
```{r}
x <- c(NA, NaN)
is.na(x)
is.nan(x)
```
You get these from mathematical operations that don't have a well defined answer
```{r}
0 / 0
0 * Inf
Inf - Inf
sqrt(-1)
log(-1)
```
```{r}
sqrt(-1 + 0i)
log(-1 + 0i)
```