You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the current implementation, fill() ignores NaN. My current workaround has been a (rather strange-looking) use of replace_na() to replace NaN with NA before passing the values to fill():
X<-tibble::tibble(x= c(1,0,3,0),
y= c(2,0,2,0),
z=x/y)
tidyr::fill(X, z)
# # A tibble: 4 x 3# x y z# <dbl> <dbl> <dbl># 1 1 2 0.5# 2 0 0 NaN# 3 3 2 1.5# 4 0 0 NaNtidyr::replace_na(X, list(z=NA)) %>%
tidyr::fill(z)
# # A tibble: 4 x 3# x y z# <dbl> <dbl> <dbl># 1 1 2 0.5# 2 0 0 0.5# 3 3 2 1.5# 4 0 0 1.5
I believe it would be warranted to have fill() treat NaN and NA equivalently, because 1) it is already done so by replace_na(), and 2) is.na(NaN) is TRUE.
The text was updated successfully, but these errors were encountered:
Dear tidyverse developers,
In the current implementation,
fill()
ignoresNaN
. My current workaround has been a (rather strange-looking) use ofreplace_na()
to replaceNaN
withNA
before passing the values tofill()
:I believe it would be warranted to have
fill()
treatNaN
andNA
equivalently, because 1) it is already done so byreplace_na()
, and 2)is.na(NaN)
isTRUE
.The text was updated successfully, but these errors were encountered: