在编辑器中不起作用

在编辑器中不起作用

本文介绍了Rstudio:Cmd + C/V 在编辑器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 pipe 在 Mac OSX 10.9.5 上的 Rstudio (v0.99.467) 和 Excel 之间复制和粘贴数据.

I have used pipe to copy and paste data between Rstudio (v0.99.467) and Excel on my Mac OSX 10.9.5.

pipe("pbcopy", "w")
pipe("pbpaste")

有一段时间,我尝试使用 pipe("pbcopy", "r"),但 Rstudio 没有响应(因为我的代码错误).过了一会儿,我发现 Cmd + C/V 不再在编辑器中工作(但它仍然在 R 控制台中工作).我重新安装了R-studio,去掉了.rstudio-desktop,问题依旧.有谁知道发生了什么?我可以删除存储 Rstudio 快捷方式首选项的 .bash 文件吗(假设重新安装不会删除它)?顺便说一句,Rstudio 中的快捷方式 .bash 文件在哪里?

For some time, I tried to use pipe("pbcopy", "r"), but Rstudio is not responding (because my code is wrong). After a while, I found Cmd + C/V is not working in the editor any more (but it still works in the R console). I re-install R-studio, removed .rstudio-desktop, the problem still exists. Does anyone know what is going on? Can I remove the .bash file that stores the Rstudio shortcut preferences (assuming re-install won't delete it)? BTW, where is the shortcut .bash file in Rstudio?

推荐答案

在使用 R 3.5.1 的 OSX Mojave 上,您可以使用以下块来捕获剪贴板:

On OSX Mojave using R 3.5.1, you can use the following block to capture the clipboard:

clipboard <- system("pbpaste", intern = T)

我还可以确认以下块正在工作:

I can also confirm that the following block is working:

clipboard <- scan(pipe("pbpaste", "r"), what = character())

然而,连接有时很难处理.例如:

However, connections are sometimes tricky to work with. For example:

clipboard <- readLines(pipe("pbpaste", "r"))

返回一个空字符向量,可能是因为剪贴板中没有换行符!

Returns an empty character vector, likely because there's no newline terminator in the clipboard!

这篇关于Rstudio:Cmd + C/V 在编辑器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 06:42