如何将列表移到r中的Word文档中?

时间:2018-07-26 11:12:43

标签: r

请您就如何将K中生成的列表移动到可以编辑的Word文档中向我提出建议。

下面是列表的一个示例,我已对其进行剪切和粘贴。但是我想使其更加专业,并添加和删除列等。

非常感谢

[[1]]
[[1]]summary
 Absolute.Neg.100 Absolute.Pos.100
 Min.   : 3.823   Min.   : 5.807  
 1st Qu.: 5.666   1st Qu.: 5.907  
 Median : 6.846   Median : 6.960  
 Mean   : 7.491   Mean   : 7.913  
 3rd Qu.: 8.380   3rd Qu.: 8.966  
 Max.   :20.874   Max.   :11.925  
 NA's   :12       NA's   :76      

[[1]]Wilcox. Test

Wilcoxon rank sum test with continuity correction

data: data[, 1]data[, 2] W = 117p-value = 0.6493 替代假设:真实的位置偏移不等于0

1 个答案:

答案 0 :(得分:0)

一种方法是使用R Markdown将输出与knitr::kable()函数一起输出到Microsoft Word,并打印为表格。

例如:

---
title: "Sample output"
author: "Len Greski"
date: "July 26, 2018"
output: word_document
---

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

## R Markdown

This is an R Markdown document illustrating an answer to Stackoverflow question about printing output in a nice format in Microsoft Word, [51537478](https://stackoverflow.com/questions/51537478/how-do-i-move-a-list-into-a-word-document-in-r). The `knitr::kable()` function can be used to generate tables in an R Markdown document, which can be used to write output to Microsoft Word. 

We'll use the sample `cars` data set and print the output of the `summary()` function with `knitr::kable()`. 

```{r cars}
library(knitr)
kable(summary(cars))
```

创建以下Microsoft Word文档:

enter image description here

相关问题