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
When using replace_na with a grouped data frame the resulting data frame is no longer grouped. Is this desired behavior? If it is could we add a note to the replace_na help page?
library(dplyr)
library(tidyr)
df<- data_frame(team= sample(letters[1:5], size=25, replace=T), points= rlnorm(25, 3, .25))
df$points[c(3, 7, 14, 20)] <-NAgrouped_df<- group_by(df, team)
grouped_df %>% summarize(mean_ppg= mean(points))
#> # A tibble: 5 x 2#> team mean_ppg#> <chr> <dbl>#> 1 a 19.02352#> 2 b NA#> 3 c NA#> 4 d NA#> 5 e 20.73076fixed_nas<-grouped_df %>%
replace_na(replace=list(points=15))
fixed_nas %>% summarize(mean_ppg= mean(points))
#> # A tibble: 1 x 1#> mean_ppg#> <dbl>#> 1 20.89099
groups(grouped_df)
#> [[1]]#> team
groups(fixed_nas)
#> NULL
The text was updated successfully, but these errors were encountered:
When using
replace_na
with a grouped data frame the resulting data frame is no longer grouped. Is this desired behavior? If it is could we add a note to thereplace_na
help page?The text was updated successfully, but these errors were encountered: