2024-04-25 12:07:58 发布
网友
我有一个简单的问题,我用下面的方法运行一个线性模型
model1 <- lm(output ~. , data=df)
我得到一些输出,我想直接提取线性方程,而不是看到原始形式的输出
我知道扫帚包我最擅长的是
library(broom) tidy(mod1)
我想要形式上的输出
output=1.1*var1 + 1.2*var2+....
您应该看看equatiomatic包(https://github.com/datalorax/equatiomatic)
下面的代码应该可以解决你的问题,我用虹膜为例
remotes::install_github("datalorax/equatiomatic") library(equatiomatic) mod1 <- lm(Petal.Width~.-Species, data= iris) extract_eq(mod1, use_coefs = TRUE, wrap=TRUE,fix_signs = FALSE,ital_vars = TRUE,terms_per_line = 4)
您应该看看equatiomatic包(https://github.com/datalorax/equatiomatic)
下面的代码应该可以解决你的问题,我用虹膜为例
相关问题 更多 >
编程相关推荐