如何使用 RMarkdown 从统计测试中获得更好的 Word 输出?

问题描述

大多数情况下,统计检验的结果是 list。我知道我只能将 kable 与数据框一起使用。以下示例是 Kolmogorov-Smirnov 测试 (ks.test)。 psych 图书馆也有很多。 我想要更好的输出编织到 Word。如何使用 a 之类的列表完成此操作?

---
title: "ks test"
output:
  word_document: default
---

```{r setup,include=FALSE}
library(knitr)
knitr::opts_chunk$set(echo = TRUE,results="asis")
```


```{r}
x <- rnorm(50)
y <- runif(30)
# Do x and y come from the same distribution?
a <- ks.test(x,y)
a
```

解决方法

您是否可以嵌入包含此测试信息的表格?

library(parameters)

x <- rnorm(50)
y <- runif(30)
# Do x and y come from the same distribution?
mod <- ks.test(x,y)

print_html(model_parameters(mod))

enter image description here