简体   繁体   English

通过剪贴板将数据从R直接复制到单词表中

[英]Copying data from R directly into word table via clipboard

Sometimes is could be quite convenient to directly copy data from R into Word. 有时将R中的数据直接复制到Word中会很方便。

For example if I have the following out put in R 例如,如果我在R中输入以下内容

c(1, 2)
[1] 1 2

When I copy the output and try to paste it into a Word table with 1 row and 2 columns it doesn't work as the output will only be copied in into only one cell. 当我复制输出并尝试将其粘贴到具有1行2列的Word表中时,它将不起作用,因为输出将仅复制到一个单元格中。

Is there a quick way to do this? 有快速的方法吗?

You can use the flextable package to create an MS Office table in Word. 您可以使用flextable包在Word中创建MS Office表。

library(flextable)
ft <- flextable(head(iris))
print(ft, preview = 'docx') # this will open a new word file with the table pasted in

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM