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

data_tabulate() gains a weights argument #479

Merged
merged 9 commits into from
Feb 7, 2024
Merged

Conversation

strengejacke
Copy link
Member

@strengejacke strengejacke commented Feb 7, 2024

library(datawizard)
data(efc, package = "datawizard")
set.seed(123)
efc$weights <- abs(rnorm(n = nrow(efc), mean = 1, sd = 0.5))

# unweighted
data_tabulate(efc$e42dep)
#> elder's dependency (efc$e42dep) <categorical>
#> # total N=100 valid N=97
#> 
#> Value |  N | Raw % | Valid % | Cumulative %
#> ------+----+-------+---------+-------------
#> 1     |  2 |  2.00 |    2.06 |         2.06
#> 2     |  4 |  4.00 |    4.12 |         6.19
#> 3     | 28 | 28.00 |   28.87 |        35.05
#> 4     | 63 | 63.00 |   64.95 |       100.00
#> <NA>  |  3 |  3.00 |    <NA> |         <NA>

# weighted
data_tabulate(efc$e42dep, weights = efc$weights)
#> elder's dependency (efc$e42dep) <categorical>
#> # total N=105 valid N=100
#> 
#> Value |  N | Raw % | Valid % | Cumulative %
#> ------+----+-------+---------+-------------
#> 1     |  3 |  2.86 |    3.00 |         3.00
#> 2     |  4 |  3.81 |    4.00 |         7.00
#> 3     | 26 | 24.76 |   26.00 |        33.00
#> 4     | 67 | 63.81 |   67.00 |       100.00
#> <NA>  |  5 |  4.76 |    <NA> |         <NA>

Created on 2024-02-07 with reprex v2.1.0

Copy link

codecov bot commented Feb 7, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (d129767) 89.47% compared to head (bdee115) 89.85%.

❗ Current head bdee115 differs from pull request most recent head b0fbf91. Consider uploading reports for the commit b0fbf91 to get more accurate results

Files Patch % Lines
R/data_tabulate.R 82.92% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #479      +/-   ##
==========================================
+ Coverage   89.47%   89.85%   +0.38%     
==========================================
  Files          72       72              
  Lines        5453     5452       -1     
==========================================
+ Hits         4879     4899      +20     
+ Misses        574      553      -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@etiennebacher etiennebacher left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM, just one minor formatting note

R/data_tabulate.R Outdated Show resolved Hide resolved
@strengejacke strengejacke merged commit 3be20ad into main Feb 7, 2024
22 of 25 checks passed
@strengejacke strengejacke deleted the data_tabulate_weights branch February 7, 2024 15:07
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.

2 participants