简体   繁体   English

在剪贴板中存储字符串(复制/粘贴)

[英]Store Character String in Clipboard (Copy/Paste)

I have the following character string in R:我在 R 中有以下字符串:

x <- "ABC"

Now, I want to use some R code to copy this character string into my cache (ie as I could do with the keyboard shortcut Ctrl + c ).现在,我想使用一些 R 代码将此字符串复制到我的缓存中(即我可以使用键盘快捷键Ctrl + c )。

I assume there must be something like copy_function(x) , but I didn't find any appropriate R code.我认为一定有类似copy_function(x)的东西,但我没有找到任何合适的 R 代码。

As final result, the keyboard shortcut Ctrl + v should print "ABC" .作为最终结果,键盘快捷键Ctrl + v应该打印"ABC"

How could I copy a character string with a function in R?如何在 R 中复制带有 function 的字符串?

We can use writeClipboard(x) .我们可以使用writeClipboard(x)

From help("writeClipboard")help("writeClipboard")

Transfer text between a character vector and the Windows clipboard in MS Windows (only).在字符向量和 MS Windows 中的 Windows 剪贴板之间传输文本(仅限)。

Then we can either press CTRL + V or call然后我们可以按CTRL + V或调用

readClipboard()
# [1] "ABC"

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

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