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

report_sample: add effective n (closes #306) #307

Merged
merged 2 commits into from
Dec 13, 2022
Merged

report_sample: add effective n (closes #306) #307

merged 2 commits into from
Dec 13, 2022

Conversation

rempsyc
Copy link
Sponsor Member

@rempsyc rempsyc commented Dec 12, 2022

Closes #306


devtools::load_all("D:/github/forks/report")
#> ℹ Loading report

report_sample(airquality, n = TRUE)
#> # Descriptive Statistics
#> 
#> Variable             |             Summary
#> ------------------------------------------
#> Mean Ozone (SD), n   |  42.13 (32.99), 116
#> Mean Solar.R (SD), n | 185.93 (90.06), 146
#> Mean Wind (SD), n    |    9.96 (3.52), 153
#> Mean Temp (SD), n    |   77.88 (9.47), 153
#> Mean Month (SD), n   |    6.99 (1.42), 153
#> Mean Day (SD), n     |   15.80 (8.86), 153

report_sample(airquality, group_by = "Month", n = TRUE)
#> # Descriptive Statistics
#> 
#> Variable             |            5 (n=31) |           6 (n=30) |           7 (n=31) |           8 (n=31) |           9 (n=30) |       Total (n=153)
#> ----------------------------------------------------------------------------------------------------------------------------------------------------
#> Mean Ozone (SD), n   |   23.62 (22.22), 26 |   29.44 (18.21), 9 |  59.12 (31.64), 26 |  59.96 (39.68), 26 |  31.45 (24.14), 29 |  42.13 (32.99), 116
#> Mean Solar.R (SD), n | 181.30 (115.08), 27 | 190.17 (92.88), 30 | 216.48 (80.57), 31 | 171.86 (76.83), 28 | 167.43 (79.12), 30 | 185.93 (90.06), 146
#> Mean Wind (SD), n    |    11.62 (3.53), 31 |   10.27 (3.77), 30 |    8.94 (3.04), 31 |    8.79 (3.23), 31 |   10.18 (3.46), 30 |    9.96 (3.52), 153
#> Mean Temp (SD), n    |    65.55 (6.85), 31 |   79.10 (6.60), 30 |   83.90 (4.32), 31 |   83.97 (6.59), 31 |   76.90 (8.36), 30 |   77.88 (9.47), 153
#> Mean Day (SD), n     |    16.00 (9.09), 31 |   15.50 (8.80), 30 |   16.00 (9.09), 31 |   16.00 (9.09), 31 |   15.50 (8.80), 30 |   15.80 (8.86), 153

Note: Failing tests appear unrelated to the current PR.

@IndrajeetPatil
Copy link
Member

Nice work, @rempsyc! Thanks.

Wouldn't it be better if we default to n = TRUE?

@rempsyc
Copy link
Sponsor Member Author

rempsyc commented Dec 13, 2022

Thanks! I wasn't sure if we should set it as default or not since in many data sets there is no missing data at all so that information will be very redundant, and it makes the table larger and slightly less readable. I can change it if you still think it should be default, WDYT?

Also I couldn't find any tests for this function... I'm going to write some then. And should I be using mostly snapshots here as well?

@IndrajeetPatil
Copy link
Member

Ah, yes, that's a good point. Okay, let's stick to n = FALSE then.

And, yes, please feel free to add some snapshot tests for this function.

@rempsyc
Copy link
Sponsor Member Author

rempsyc commented Dec 13, 2022

Added snapshot tests; all tests for report_sample pass. However, I have commented tests for the weights argument as I don't understand what I need to pass it. It says a character vector indicating the name of a potential weight-variable, but my attempts so far were not successful, as I am not familiar with weighting procedures generally.

Copy link
Member

@IndrajeetPatil IndrajeetPatil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

We can come back to the weights issue later.

@IndrajeetPatil IndrajeetPatil merged commit f661ec6 into easystats:main Dec 13, 2022
@rempsyc rempsyc deleted the report_sample_n branch December 13, 2022 19:21
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

Successfully merging this pull request may close these issues.

Effective sample size per row, not total sample size in report_sample
2 participants