如何为 r 中的转换变量创建汇总统计 table
How to create a summary statistics table for transformed variables in r
我想在 r 中为转换后的变量创建汇总统计信息 table。变量是 X、Y 和 Z。这些变量有它们的原始值。汇总统计数据 table 可以在 R 中创建,如下所示:
dataSumStatTable <- my.dataframe %>% select(X,Y,Z)
sum1 <- sumtable(dataSumStatTable,
summ=c('min(x)','mean(x)','max(x)','sd(x)','notNA(x)'),
title="Summary Statistics",
summ.names=c('Min','Mean','Max','SD','Observations'),
col.align=c('center','center','center', 'center', 'center'),
labels=c('X',
'Y',
'Z',
group.long = TRUE,
digits = 2,
fixed.digits = TRUE,
align = TRUE,
out = "viewer")
但是,我在回归模型中使用这些变量,其中所有变量都在对数中。如何在日志中为我的变量创建摘要统计信息table?
您可以先对要汇总的数据调用log
。
例如:
未转换的摘要:
> mtcars |> select(hp, drat, wt) |> summary()
hp drat wt
Min. : 52.0 Min. :2.760 Min. :1.513
1st Qu.: 96.5 1st Qu.:3.080 1st Qu.:2.581
Median :123.0 Median :3.695 Median :3.325
Mean :146.7 Mean :3.597 Mean :3.217
3rd Qu.:180.0 3rd Qu.:3.920 3rd Qu.:3.610
Max. :335.0 Max. :4.930 Max. :5.424
变形:
> mtcars |> select(hp, drat, wt) |> log() |> summary()
hp drat wt
Min. :3.951 Min. :1.015 Min. :0.4141
1st Qu.:4.570 1st Qu.:1.125 1st Qu.:0.9479
Median :4.812 Median :1.307 Median :1.2009
Mean :4.882 Mean :1.269 Mean :1.1217
3rd Qu.:5.193 3rd Qu.:1.366 3rd Qu.:1.2835
Max. :5.814 Max. :1.595 Max. :1.6908
我想在 r 中为转换后的变量创建汇总统计信息 table。变量是 X、Y 和 Z。这些变量有它们的原始值。汇总统计数据 table 可以在 R 中创建,如下所示:
dataSumStatTable <- my.dataframe %>% select(X,Y,Z)
sum1 <- sumtable(dataSumStatTable,
summ=c('min(x)','mean(x)','max(x)','sd(x)','notNA(x)'),
title="Summary Statistics",
summ.names=c('Min','Mean','Max','SD','Observations'),
col.align=c('center','center','center', 'center', 'center'),
labels=c('X',
'Y',
'Z',
group.long = TRUE,
digits = 2,
fixed.digits = TRUE,
align = TRUE,
out = "viewer")
但是,我在回归模型中使用这些变量,其中所有变量都在对数中。如何在日志中为我的变量创建摘要统计信息table?
您可以先对要汇总的数据调用log
。
例如:
未转换的摘要:
> mtcars |> select(hp, drat, wt) |> summary()
hp drat wt
Min. : 52.0 Min. :2.760 Min. :1.513
1st Qu.: 96.5 1st Qu.:3.080 1st Qu.:2.581
Median :123.0 Median :3.695 Median :3.325
Mean :146.7 Mean :3.597 Mean :3.217
3rd Qu.:180.0 3rd Qu.:3.920 3rd Qu.:3.610
Max. :335.0 Max. :4.930 Max. :5.424
变形:
> mtcars |> select(hp, drat, wt) |> log() |> summary()
hp drat wt
Min. :3.951 Min. :1.015 Min. :0.4141
1st Qu.:4.570 1st Qu.:1.125 1st Qu.:0.9479
Median :4.812 Median :1.307 Median :1.2009
Mean :4.882 Mean :1.269 Mean :1.1217
3rd Qu.:5.193 3rd Qu.:1.366 3rd Qu.:1.2835
Max. :5.814 Max. :1.595 Max. :1.6908