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
I was fixing some Arrow test failures which are the result of the dev version of waldo correctly distinguishing between NA_real_ and NaN, and came across this behaviour where NaN values are silently coerced by dplyr::coalesce() into NAs.
I'm unsure if this is a bug or just a difference in implementations/interpretations, but the second row in the cwx column in the example below is making me think it could be a bug?
library(dplyr)
library(arrow)
df<- tibble(
w= c(NaN, NaN, NA_real_),
x= c(NA_real_, NaN, 3.3),
y= c(NA_real_, 2.2, 3.3),
z= c(1.1, 2.2, 3.3)
)
df %>%
mutate(
cw= coalesce(w),
cz= coalesce(z),
cwx= coalesce(w, x),
cwxy= coalesce(w, x, y),
cwxyz= coalesce(w, x, y, z)
)
#> # A tibble: 3 × 9#> w x y z cw cz cwx cwxy cwxyz#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>#> 1 NaN NA NA 1.1 NA 1.1 NA NA 1.1#> 2 NaN NaN 2.2 2.2 NA 2.2 NA 2.2 2.2#> 3 NA 3.3 3.3 3.3 NA 3.3 3.3 3.3 3.3df %>%
arrow_table() %>%
mutate(
cw= coalesce(w),
cz= coalesce(z),
cwx= coalesce(w, x),
cwxy= coalesce(w, x, y),
cwxyz= coalesce(w, x, y, z)
) %>%
collect()
#> # A tibble: 3 × 9#> w x y z cw cz cwx cwxy cwxyz#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>#> 1 NaN NA NA 1.1 NaN 1.1 NA NA 1.1#> 2 NaN NaN 2.2 2.2 NaN 2.2 NaN 2.2 2.2#> 3 NA 3.3 3.3 3.3 NA 3.3 3.3 3.3 3.3
I was fixing some Arrow test failures which are the result of the dev version of waldo correctly distinguishing between
NA_real_
andNaN
, and came across this behaviour whereNaN
values are silently coerced bydplyr::coalesce()
intoNA
s.I'm unsure if this is a bug or just a difference in implementations/interpretations, but the second row in the
cwx
column in the example below is making me think it could be a bug?Created on 2023-04-24 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: