Git Product home page Git Product logo

Comments (3)

LukaszDerylo avatar LukaszDerylo commented on July 29, 2024

Obviously ff_label works in this simple example.

For larger and more general case I have a workaround:

  dt<-data.frame(
    y=factor(c('yes','yes','yes','no','no','no')) ,
    x1=c(1,3,5,2,4,6),
    `second x`=c(1,2,4,6,5,3),
    x3=1:6,
    check.names=F
  )

  
IV<-c('x1', 'second x')     # notice no backticks here!!! !
DV<-'y'
  
dt<-dt[,c(DV,IV)] # drop varialbes not used in model

cn<-colnames(dt) # remember original colnames

dt <- dt %>% 
  data.frame() %>% # replace spaces etc. with dots
  ff_relabel(cn)  # assign original colnames as labels
  
finalfit(dt,
         dependent=make.names(DV),
         explanatory=make.names(IV))  # run model with dots in colnames and nice labels

This gives what I want:

  Dependent: y                  no       yes          OR (univariable)      OR (multivariable)
2           x1 Mean (SD) 4.0 (2.0) 3.0 (2.0) 0.70 (0.20-1.83, p=0.485) 0.50 (NA-2.97, p=0.600)
1     second x Mean (SD) 4.7 (1.5) 2.3 (1.5) 0.30 (0.02-1.07, p=0.183) 0.22 (NA-1.08, p=0.347)

Is there an easier way to do that?

from finalfit.

ewenharrison avatar ewenharrison commented on July 29, 2024

Thanks Łukasz. In our own work we usually avoid non-standard column names and use labels to display the output we want. Base R GLM and summary_factorlist() treat back-ticks different. summary_factorlist() is being re-written at the moment, so this may automatically be fixed. In the meantime, this is a hacky workaround but requires ff_merge() methods .

ff_merge(
  summary_factorlist(dt, dependent, explanatory, fit_id = TRUE),
  glmmulti(dt, dependent, explanatory) %>% 
    fit2df() %>% 
    mutate(
      explanatory = gsub("`", "", explanatory)
    ),
  last_merge = TRUE
)

from finalfit.

LukaszDerylo avatar LukaszDerylo commented on July 29, 2024

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.