首页 > 解决方案 > 'finalfit' loses labels when processing a continuous dependent variable

问题描述

Normally, the function finalfit in the finalfit package shows a regression table with variable's labels. https://finalfit.org/articles/all_tables_examples.html#cross-tables

However, when a continuous variable including large amount of missing values is used as dependent variable, the function does not show labels but variables' names.

example

library(finalfit)
library(dplyr)
colon_s %>% 
  finalfit("nodes", "age") # "age" has label "Age (years)"

output

Dependent is not a factor and will be treated as a continuous variable
  Dependent: nodes         Mean (sd)       Coefficient (univariable)
1              age [18,85] 3.7 (3.6) -0.03 (-0.05 to -0.01, p=0.005)
      Coefficient (multivariable)
1 -0.03 (-0.05 to -0.01, p=0.005)

Can I fix it or is it inappropriate to use continuous variables?

device information

version
               _                           
platform       x86_64-apple-darwin15.6.0   
arch           x86_64                      
os             darwin15.6.0                
system         x86_64, darwin15.6.0        
status                                     
major          3                           
minor          6.2                         
year           2019                        
month          12                          
day            12                          
svn rev        77560                       
language       R                           
version.string R version 3.6.2 (2019-12-12)
nickname       Dark and Stormy Night   
packageVersion("finalfit")
[1] ‘0.9.7’
packageVersion("dplyr")
[1] ‘0.8.3’

RStudio Version 1.2.5033

标签: rdplyrrstudio

解决方案


Thanks.

This should work if you use finalfit 1.0.0, currently only available on github.

remotes::install_github('ewenharrison/finalfit')
library(finalfit)

colon_s %>% 
  finalfit("nodes", "age")

 Dependent: nodes              unit     value       Coefficient (univariable)     Coefficient (multivariable)
      Age (years) [18,85] Mean (sd) 3.7 (3.6) -0.03 (-0.05 to -0.01, p=0.005) -0.03 (-0.05 to -0.01, p=0.005)

Thanks again.


推荐阅读