Git Product home page Git Product logo

Comments (2)

ewenharrison avatar ewenharrison commented on September 4, 2024

Thanks Omar, it's a good idea. Appreciate your thoughts on this.

There's the ff_remove_ref() function for regression tables, but nothing that will currently work after summary_factorlist().

This should work for all instances. Looks awful of course but if useful could be wrapped up into a nicer function.

Let me know what you think.

explanatory = c("age", "nodes", "age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
dependent = 'mort_5yr'

colon_s %>%
	summary_factorlist(dependent, explanatory, column = TRUE) %>% 
	dplyr::mutate(label = ifelse(label == "", NA, label)) %>% 
	tidyr::fill(label) %>%
	dplyr::group_by(label) %>% 
	dplyr::filter(levels %in% c("Mean (SD)", "Median (IQR)") | row_number() != 1) %>% 
	dplyr::ungroup() %>% 
	dplyr::mutate_at(-c(1, 2), ~ stringr::str_extract(., "(?<=\\().+?(?=\\))")) %>% 
	rm_duplicate_labels() %>% 
	data.frame()

from finalfit.

ewenharrison avatar ewenharrison commented on September 4, 2024

This is done.

explanatory = c("age", "age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
dependent = 'mort_5yr'
colon_s %>%
	summary_factorlist(dependent, explanatory)
         label      levels       Alive        Died
1  Age (years)   Mean (SD) 59.8 (11.4) 59.9 (12.5)
2          Age   <40 years    31 (6.1)    36 (8.9)
3              40-59 years  208 (40.7)  131 (32.4)
4                60+ years  272 (53.2)  237 (58.7)
9          Sex      Female  243 (47.6)  194 (48.0)
10                    Male  268 (52.4)  210 (52.0)
5  Obstruction          No  408 (82.1)  312 (78.6)
6                      Yes   89 (17.9)   85 (21.4)
7  Perforation          No  497 (97.3)  391 (96.8)
8                      Yes    14 (2.7)    13 (3.2)

colon_s %>%
	summary_factorlist(dependent, explanatory) %>% 
	ff_remove_ref() %>% 
	ff_percent_only()

        label      levels       Alive        Died
1 Age (years)   Mean (SD) 59.8 (11.4) 59.9 (12.5)
2         Age   <40 years         6.1         8.9
3             40-59 years        40.7        32.4
4               60+ years        53.2        58.7
5         Sex        Male        52.4        52.0
6 Obstruction         Yes        17.9        21.4
7 Perforation         Yes         2.7         3.2

from finalfit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.