jstable icon indicating copy to clipboard operation
jstable copied to clipboard

About TableSubgroupMultiGLM

Open Song-liu-x opened this issue 8 months ago • 1 comments

First of all, I would like to thank the author for writing this function, but I have noticed that there seem to be some errors. I hope the author can provide an answer. When using the #TableSubgroupMultiGLM function with family="Gaussian" and date = data.design, an error will occur if the subgroup variable is a categorical variable with more than three levels.

For example,

library(survey) lung %>% mutate( status = as.integer(status == 1), sex = factor(sex), kk = factor(ifelse(pat.karno < 70,1, ifelse(pat.karno >= 70 & pat.karno <= 90,2,3))) ) -> lung data.design <- svydesign(id = ~1, data = lung) TableSubgroupMultiGLM(status ~ sex, var_subgroups = c("kk"), data = data.design, family = "gaussian" )

<error/purrr_error_indexed> Error in purrr::map(): ℹ In index: 1. Caused by error in .svycheck(): ! ..2 used in an incorrect context, no ... to look in

Backtrace: ▆

  1. ├─jstable::TableSubgroupMultiGLM(...)
  2. │ └─purrr::map(...)
  3. │ └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
  4. │ ├─purrr:::with_indexed_errors(...)
  5. │ │ └─base::withCallingHandlers(...)
  6. │ ├─purrr:::call_with_cleanup(...)
  7. │ └─jstable (local) .f(.x[[i]], ...)
  8. │ └─jstable::TableSubgroupGLM(...)
  9. │ ├─stats::anova(model.int, method = "Wald")
  10. │ └─survey:::anova.svyglm(model.int, method = "Wald")
  11. │ └─survey:::oneanova.svyglm(object, test, method)
  12. │ ├─base::eval(bquote(update(thismodel, . ~ . - (.(thisformula)))))
  13. │ │ └─base::eval(bquote(update(thismodel, . ~ . - (.(thisformula)))))
  14. │ ├─stats::update(thismodel, . ~ . - (sex:kk))
  15. │ ├─stats::update(thismodel, . ~ . - (sex:kk))
  16. │ ├─stats::update.default(thismodel, . ~ . - (sex:kk))
  17. │ │ └─base::eval(call, parent.frame())
  18. │ │ └─base::eval(call, parent.frame())
  19. │ └─survey::svyglm(formula = status ~ sex + kk, design = ..2, family = ..3)
  20. │ └─survey:::.svycheck(design)
  21. └─base::.handleSimpleError(...)
  22. └─purrr (local) h(simpleError(msg, call))
  23. └─cli::cli_abort(...)
    
  24.   └─rlang::abort(...)
    

Song-liu-x avatar Apr 03 '25 17:04 Song-liu-x

Hello. I'm sorry and I fix it

Please install the latest version via

remotes::install_github("jinseob2kim/jstable")

jinseob2kim avatar Apr 07 '25 13:04 jinseob2kim