![]() ~ifelse(.x %in% c("High", "Exposed", "Case"), TRUE, FALSE) # difficult to read in tables but so can compare directly with tab_univariate # only keep variables of interest and make them binary Mutate(exposure = factor(exposure, labels = c("Not Exposed", "Exposed")),Ĭase = factor(case, labels = c("Control", "Case")), Select(exposure = response, case = death, grade, stage) %>% # creating a dataset with case-control and exposure status This introduces some other issues, but would be a good general solution.Īnyway, these are just my initial thoughts! Will continue to think on it, and would love to hear your thoughts.ĭevtools::source_url("/ddsjoberg/a12565f21142052ba5933ab1fc36a1ba/raw/3b20b7d35eb6574953cb9bbb7a9e87edbef9d890/tbl_cmh.R") The function could stratify the results from tbl_summary(), tbl_uvregression(), tbl_cross(), etc. Perhaps the best solution is to just add a new function tbl_strata(data, additional_fns, method = c("tbl_summary"). There are also quite a few functions this would NOT work for, such as modify_header(). We could add methods add_p.tbl_merge() that would inspect the internals of the tbl_merge() object, then attempt to run add_p.tbl_summary() on each component table, then re-merge the tables.I like the API this brings to the user.but requires quite a bit of work.We could add tbl_summary(by = c(by, strata), additional_fns = ) argument, but I don't like it.There are two possible solutions I see immediately. I do like the syntax of tbl_summary(by = c(by, strata)) and I think working toward something that could make this work would be great. Therefore, you cannot use functions, such as add_p() designed to work with tbl_summary() objects. I don't know/think this was the best solution.but found it difficult to do something better.Īdd and argument to tbl_summary()? I like that solution, but is comes with a severe limitation: the output is no longer a tbl_summary() object, rather it is a tbl_merge() obejct. Tbl_summary( by = trt, include = - grade, missing = "no ") % >% Mutate( grade = paste( "Grade ", grade)) % >% But I think this should be updated to users don't see these messages if they don't include the argument. If you include tbl_summary(include = -grade) in the original call, you won't see any warning about missing grade. To include these observations, use `forcats::fct_explicit_na()` on `trt_fct` column before passing to `tbl_summary()`. #> 5 observations missing `trt_fct` have been removed. # trt as fct tbl2 % select( trt_fct, age) % >% tbl_summary( by = trt_fct) To include these observations, use `forcats::fct_explicit_na()` on `trt` column before passing to `tbl_summary()`. #> 5 observations missing `trt` have been removed. #> '1.' # Make data slightly more "messy" df %ĭf $ trt % select( trt, age) % >% tbl_summary( by = trt) Obviously I don't know the big picture here, as this function seems to be able to work for several times of objects. This would allow something like add_p() to be positioned in two places (either before the add_strata() for individualized statistics, or after for pooled statistics). I know that error checking happens in a "last in, first out" method, so perhaps the infrastructure is available. I don't know enough about R programming and pipes to know if the pipeline could also detect if add_strata() was available downstream, and then perform the function a bit differently. pooled methods, individual strata statistics, etc). That does end up with the same problem of which statistical tests to run, (e.g. One thought I had was to perhaps include the strata argument in the original tbl_summary() function, so the overhead of recomputing statistics would be lessened. Tbl_merge( tbls $ tbl, tab_spanner = str_glue( "**** ")) Tbl = tbl_summary( data, by = drivetrain, type = everything() ~ "continuous ") % >% list() Mutate( drivetrain = factor( drivetrain)) % >% Select( bdy_style, drivetrain, msrp) % >% ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |