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

get_summary_stats with grouped_data #78

Closed
dhofstetter opened this issue Nov 8, 2020 · 1 comment
Closed

get_summary_stats with grouped_data #78

dhofstetter opened this issue Nov 8, 2020 · 1 comment

Comments

@dhofstetter
Copy link

The get_summary_stats method is behaves different for grouped and ungrouped data. For grouped data, the user defined probabilites are ignored completely.

The example below shows the problem observed.

require(tidyverse)
require(assertthat)
require(rstatix)

# We need some probabilites we want to observe as quantiles
probabilities_to_observe <- c(0, .5, .66, 1)

# Create an arbitrary frame with a grouping variable (actually the groups are
# the same which is better to visualize the behavioral problem)
data <- data_frame(
    gr=as.ordered(c("G1", "G1", "G1", "G1", "G1")), 
    value=runif(5,0,10)
)

summary1 <- data %>% 
    group_by(gr) %>% 
    get_summary_stats(value, type="quantile", probs = probabilities_to_observe)

summary2 <- data %>%
    get_summary_stats(value, type="quantile", probs = probabilities_to_observe)

# Check for expected outputs
names2_to_have <- c("variable", "n", "0%", "50%", "66%", "100%")
names1_to_have <- c("gr", names2_to_have)
    
assertthat::are_equal(names(summary1), names1_to_have)
assertthat::are_equal(names(summary2), names2_to_have)

BR Daniel

kassambara added a commit that referenced this issue Feb 13, 2021
@kassambara
Copy link
Owner

fixed now, thanks

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

2 participants