将数组转换为数据框
Turning an Array into a Data Frame
我想使用 kable 函数将我的汇总统计数据放入 table,但我做不到,因为它以数组的形式出现。
```{r setup options, include = FALSE}
knitr::opts_chunk$set(fig.width = 8, fig.height = 5, echo = TRUE)
library(mosaic)
library(knitr)
```
```{r}
sum = summary(SwimRecords$time) # generic data set included with mosaic package
kable(sum) # I want this to be printed into a table
```
有什么建议吗?
您可以使用为 "tidy" 这些统计相关对象构建的 broom
包轻松做到这一点:
#install.packages(broom)
broom::tidy(sum)
我想使用 kable 函数将我的汇总统计数据放入 table,但我做不到,因为它以数组的形式出现。
```{r setup options, include = FALSE}
knitr::opts_chunk$set(fig.width = 8, fig.height = 5, echo = TRUE)
library(mosaic)
library(knitr)
```
```{r}
sum = summary(SwimRecords$time) # generic data set included with mosaic package
kable(sum) # I want this to be printed into a table
```
有什么建议吗?
您可以使用为 "tidy" 这些统计相关对象构建的 broom
包轻松做到这一点:
#install.packages(broom)
broom::tidy(sum)