Git Product home page Git Product logo

Comments (3)

tylcole avatar tylcole commented on July 29, 2024

As a temporary workaround, I wrote the function collapseBinary() which takes as input a finalfit output dataframe

In:
image

Out:
image

Function:
collapseBinary = function(.data) {
emptyRows = which(.data[,2] == "0")
.data[emptyRows, 2:6] = .data[(emptyRows + 1), 2:6]
.data = .data[-(emptyRows + 1),]
replaceWithBlank = which(.data[,2] == "1")
.data[replaceWithBlank, 2] = ""
return(.data)
}

Use:
collapsedTable = tableToCollapse %>% collapseBinary()

You may have to change whatever your binary labels are, like "No" and "Yes" instead of "0" and "1"

Hope it helps until there's something more general incorporated in the function! This would also be great for the OR plots

from finalfit.

ewenharrison avatar ewenharrison commented on July 29, 2024

Hi,
Many thanks for you interest and work on this. One of the advantages of the finalfit dataframe is that it can be edited on the fly. So rather than adding extra options to the original functions, I've added a quick helper function ff_remove_ref which will remove the rows for you. It should work with all flavors of regression and factor levels.

You can install the github version of finalfit to access this.

Example:

explanatory = c("age.factor", "age", "sex.factor", "nodes", "obstruct.factor", "perfor.factor")
dependent = 'mort_5yr'
colon_s %>%
	finalfit(dependent, explanatory, add_dependent_label = FALSE) %>% 
	ff_remove_ref() %>% 
	dependent_label(colon_s, dependent)

Altering the OR plot can be done in a similar manner. This isn't as straightfoward and some examples will be added to future vignettes. A new "factorlist" object is created only containing the levels of interest, which is then passed to or_plot().

Example:

colon_s %>% 
	summary_factorlist(dependent, explanatory, total_col = TRUE, fit_id=TRUE) %>% 
	ff_merge(
		glmuni(colon_s, dependent, explanatory) %>% 
			fit2df()) %>% 
	ff_remove_ref() %>% 
	select(-`OR`) -> factorlist_plot

colon_s %>% 
	or_plot(dependent, explanatory, factorlist = factorlist_plot)

ff_merge() is very flexible, and multiple columns can be added to a regression table using it. I'll pop a comment on your other post about that. Thanks again. Let me know if anything doesn't work.

from finalfit.

tylcole avatar tylcole commented on July 29, 2024

That's great, thank you!

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.