admin 管理员组文章数量: 1086019
I'm working with {modelsummary} to create a styling function for models. The final tables will be in Polish so I need to rename the columns with estimate and standard error names. I found this question and followed the instructions: How can I rename statistics in modelsummary?
My problem is that the estimate column gets duplicated rather than just renamed. Is there some way to actually get the column renamed rather than creating a new column? Or alternatively is there a way to get it to work with some additional {tinytable} processing? Sample code that should reproduce the issue is below
library(modelsummary)
library(tinytable)
N <- 1e4
x <- rnorm(N)
x2 <- rnorm(N, 1.3, .8)
y <- rnorm(N, 2 + .3*x - .6*x2)
df_to_lm <- data.frame(x, x2, y)
lm_totable_1 <- lm(y ~ x, df_to_lm)
lm_totable_2 <- lm(y ~ x + x2, df_to_lm)
lm_totable_3 <- lm(y ~ x*x2, df_to_lm)
modelsummary(
models = list("Model 1" = lm_totable_1,
"Model 2" = lm_totable_2,
"Model 3" = lm_totable_3),
fmt = 2,
statistic = c("B" = "{estimate}",
"Błąd Standardowy" = "{std.error}"), # Correctly renaming estimate
coef_omit = "Intercept",
shape = term ~ model + statistic,
gof_map = "r.squared"
)
I'm working with {modelsummary} to create a styling function for models. The final tables will be in Polish so I need to rename the columns with estimate and standard error names. I found this question and followed the instructions: How can I rename statistics in modelsummary?
My problem is that the estimate column gets duplicated rather than just renamed. Is there some way to actually get the column renamed rather than creating a new column? Or alternatively is there a way to get it to work with some additional {tinytable} processing? Sample code that should reproduce the issue is below
library(modelsummary)
library(tinytable)
N <- 1e4
x <- rnorm(N)
x2 <- rnorm(N, 1.3, .8)
y <- rnorm(N, 2 + .3*x - .6*x2)
df_to_lm <- data.frame(x, x2, y)
lm_totable_1 <- lm(y ~ x, df_to_lm)
lm_totable_2 <- lm(y ~ x + x2, df_to_lm)
lm_totable_3 <- lm(y ~ x*x2, df_to_lm)
modelsummary(
models = list("Model 1" = lm_totable_1,
"Model 2" = lm_totable_2,
"Model 3" = lm_totable_3),
fmt = 2,
statistic = c("B" = "{estimate}",
"Błąd Standardowy" = "{std.error}"), # Correctly renaming estimate
coef_omit = "Intercept",
shape = term ~ model + statistic,
gof_map = "r.squared"
)
Share
Improve this question
asked Mar 27 at 11:22
HonestioreHonestiore
773 bronze badges
1 Answer
Reset to default 1The estimate column is governed by the estimate
argument, not by the statistic
argument.
modelsummary(
models = list("Model 1" = lm_totable_1,
"Model 2" = lm_totable_2,
"Model 3" = lm_totable_3),
fmt = 2,
estimate = c("B" = "{estimate}"),
statistic = c("Błąd Standardowy" = "{std.error}"),
coef_omit = "Intercept",
shape = term ~ model + statistic,
gof_map = "r.squared"
)
本文标签: rmodelsummary duplicates estiamte columns instead of renamingStack Overflow
版权声明:本文标题:r - modelsummary duplicates estiamte columns instead of renaming - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744093599a2532488.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论