Comments (3)
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.
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.
Thank you!
from finalfit.
Related Issues (20)
- na_include does not work HOT 1
- ff_remove_ref() removes column totals for summary_factorlist() HOT 2
- Why the box size is different when using hr_plot to draw the figure, how to adjust it? HOT 2
- inverse OR in finalfit in R HOT 6
- finalfit does not show median, only mean HOT 1
- inverse OR in finalfit in R continuation closed event
- Fine-gray model visualization HOT 2
- Extending cont_cut to or_plot HOT 1
- Adjust axes for coef plots? HOT 1
- Multinomial Logistic Regression HOT 4
- About modifying the hr_plot function HOT 3
- Error with or_plot HOT 2
- `fct_explicit_na()` was deprecated in forcats 1.0.0 HOT 1
- missing_compare - discrepancy in the manual (Kruskal-Wallis) HOT 1
- `Namespace in Imports field not imported from: ‘tidyselect’` HOT 1
- The output from the stratified models example does not align with the results of the stratified Cox model. HOT 4
- Table format of the finalfit output only gives HTML format script HOT 4
- Potential bugs finalfit command HOT 1
- Finalfit package: Descriptive statistics query for p values and getting Median as statistics HOT 1
- p>0.05, but 95% confidence interval for the odds ratio DOES NOT include 1. How can I check and standardise the methods used to calculate the p-values and confidence intervals? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from finalfit.