如何在 R 中为具有相同变量的多个数据帧创建 table 和 summary_table (qwraps2)?
How to create a table with summary_table (qwraps2) in R for several data frames having the same variables?
我正在尝试寻找一种方法来对具有相同变量的多个数据帧使用函数 summary_table (qwraps2)。这样我最终每个 data.frame.
都有一列
这与我目前得到的相似(https://www.rdocumentation.org/packages/qwraps2/versions/0.5.0/topics/summary_table 中的示例):
libary(qwraps2)
our_summary1 <-
list("Miles Per Gallon" =
list("min" = ~ min(mpg),
"max" = ~ max(mpg),
"mean (sd)" = ~ qwraps2::mean_sd(mpg)),
"Displacement" =
list("min" = ~ min(disp),
"median" = ~ median(disp),
"max" = ~ max(disp),
"mean (sd)" = ~ qwraps2::mean_sd(disp)),
"Weight (1000 lbs)" =
list("min" = ~ min(wt),
"max" = ~ max(wt),
"mean (sd)" = ~ qwraps2::mean_sd(wt)),
"Forward Gears" =
list("Three" = ~ qwraps2::n_perc0(gear == 3),
"Four" = ~ qwraps2::n_perc0(gear == 4),
"Five" = ~ qwraps2::n_perc0(gear == 5))
)
orig_opt <- options()$qwraps2_markup
options(qwraps2_markup = "markdown")
whole <- summary_table(mtcars2, our_summary1)
whole
但是如何在其中获得第二个、第三个 data.frame?
我试过类似的方法:
mtcars2.copy<-data.frame(mtcars2)
whole_table= summary_table(c(mtcars2,mtcars2.copy), our_summary1)
```
But it didn't work...
好的,我想我找到了解决方案:
whole_table= summary_table(mtcars2, our_summary1)
whole_table2= summary_table(mtcars3, our_summary1)
cbind(whole_table,whole_table2)
我正在尝试寻找一种方法来对具有相同变量的多个数据帧使用函数 summary_table (qwraps2)。这样我最终每个 data.frame.
都有一列这与我目前得到的相似(https://www.rdocumentation.org/packages/qwraps2/versions/0.5.0/topics/summary_table 中的示例):
libary(qwraps2)
our_summary1 <-
list("Miles Per Gallon" =
list("min" = ~ min(mpg),
"max" = ~ max(mpg),
"mean (sd)" = ~ qwraps2::mean_sd(mpg)),
"Displacement" =
list("min" = ~ min(disp),
"median" = ~ median(disp),
"max" = ~ max(disp),
"mean (sd)" = ~ qwraps2::mean_sd(disp)),
"Weight (1000 lbs)" =
list("min" = ~ min(wt),
"max" = ~ max(wt),
"mean (sd)" = ~ qwraps2::mean_sd(wt)),
"Forward Gears" =
list("Three" = ~ qwraps2::n_perc0(gear == 3),
"Four" = ~ qwraps2::n_perc0(gear == 4),
"Five" = ~ qwraps2::n_perc0(gear == 5))
)
orig_opt <- options()$qwraps2_markup
options(qwraps2_markup = "markdown")
whole <- summary_table(mtcars2, our_summary1)
whole
但是如何在其中获得第二个、第三个 data.frame?
我试过类似的方法:
mtcars2.copy<-data.frame(mtcars2)
whole_table= summary_table(c(mtcars2,mtcars2.copy), our_summary1)
```
But it didn't work...
好的,我想我找到了解决方案:
whole_table= summary_table(mtcars2, our_summary1)
whole_table2= summary_table(mtcars3, our_summary1)
cbind(whole_table,whole_table2)