如何从剪贴板中将数据复制并粘贴到R中? [英] How do I copy and paste data into R from the clipboard?
本文介绍了如何从剪贴板中将数据复制并粘贴到R中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
标题说明了一切:我在另一个应用程序(例如电子表格,如Excel或文本编辑器)中打开了我的数据。如果我将该数据复制到我的操作系统剪贴板,如何将其作为data.frame读入R?
The title says it all: I have my data open in another application (e.g., a spreadsheet, like Excel, or a text editor). If I copy that data to my operating system clipboard, how can I read it into R as a data.frame?
推荐答案
假设您在Windows剪贴板中有数据(例如,从Excel复制的数据),将该数据放入R使用中名为 copdat
的变量中:
Assuming you have data in the Windows clipboard (for example, copied data from Excel), to put that data into a variable named copdat
in R use:
copdat <- read.delim("clipboard")
如果要将名为 rdat
的R变量中的数据复制到Windows剪贴板中(例如,要复制到Excel中),请使用:
If you want to copy data from an R variable named rdat
into the Windows clipboard (for example, to copy into Excel) use:
write.table(rdat, "clipboard", sep="\t", row.names=FALSE, col.names=FALSE)
这篇关于如何从剪贴板中将数据复制并粘贴到R中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文