-
Notifications
You must be signed in to change notification settings - Fork 130
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
Bug: tbl_svysummary()
INDEX error
#2092
Comments
**What changes are proposed in this pull request?** * Update in `ard_missing.survey.design()` where we can now tabulate the missing rate of design variables, such as the weights. **Reference GitHub issue associated with pull request.** _e.g., 'closes #<issue number>'_ ddsjoberg/gtsummary#2092 -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [x] **All** GitHub Action workflows pass with a ✅ - [x] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [x] If a bug was fixed, a unit test was added. - [x] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [x] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [x] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom""))` - [x] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [ ] If a bug was fixed, a unit test was added. - [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] **All** GitHub Action workflows pass with a ✅ - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge".
Hi @larmarange , It looks like this error arises from library(magrittr)
dplyr::tribble(
~region, ~year, ~weights,
3, 1972, 0.663196271930943,
3, 1972, 0.917370028585327,
3, 1972, 0.897412512251031,
3, 1972, 1.06634082743438,
3, 1972, 0.94432371066466,
3, 1972, 0.526887241987567,
3, 1972, 0.526887241987567,
3, 1972, 0.546578869586901,
7, 1972, 0.283198307048893,
7, 1972, 0.494322145606406
) %>%
survey::svydesign(
data = .,
ids = ~region,
strata = ~year,
weights = ~weights,
nest = TRUE
) %>%
survey::svytable(formula = ~weights, design = .)
#> Error in tapply(y, by, sum, na.rm = na.rm, default = 0L): 'INDEX' is of length zero Created on 2024-12-27 with reprex v2.1.1 |
Yes, However, I do not see when generating such table. I do understand that you are interested by looking at the weighting variable. But in that case you will perform a |
Thanks for the details @larmarange ! I'll close it out and if someone raises it with survey in the future that'll be sufficient. |
Created on 2024-12-03 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: