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

when a subset has only missing value, survey_median will break instead of returning 0 or NA for that group. #182

Open
yannsay-impact opened this issue Nov 28, 2024 · 0 comments

Comments

@yannsay-impact
Copy link

library(srvyr)
repex_df <- data.frame(group = c(rep("a", 5), rep("b",3)),
                       variable_x = c(runif(5), rep(NA, 3)))
data_survey_design <- srvyr::as_survey(repex_df)
data_survey_design |>
  group_by(group) |>
  summarise(survey_median(variable_x, na.rm = T)) 

image

data_survey_design |>
  group_by(group) |>
  summarise(survey_mean(variable_x, na.rm = T)) 

image

Thanks @Ahmed-REACH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant