如何将数据从剪贴板复制并粘贴到 R 中? [英] How do I copy and paste data into R from the clipboard?

查看:40
本文介绍了如何将数据从剪贴板复制并粘贴到 R 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在另一个应用程序(例如电子表格,如 Excel 或文本编辑器)中打开了我的数据.如果我将该数据复制到我的操作系统剪贴板,我如何将它作为 data.frame 读入 R?

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 复制的数据),将该数据放入名为 copdat 在 R 中使用:

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="	", row.names=FALSE, col.names=FALSE)

这篇关于如何将数据从剪贴板复制并粘贴到 R 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆