user10394751
user10394751

Reputation:

Turning an Array into a Data Frame

I would like to put my summary statistics into a table using the kable function, but I cannot because it comes up as an array.

```{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
```

Any suggestions?

Upvotes: 0

Views: 69

Answers (1)

JohnCoene
JohnCoene

Reputation: 2261

You can do so easily with the broom package which is built to "tidy" these stats-related objects:

#install.packages(broom)
broom::tidy(sum)

Upvotes: 1

Related Questions