我正在运行Ubuntu 11.10,我希望能够写入剪贴板(或主要选择)。下面给出了一个错误如何在R/Ubuntu上写入到Ubuntu/Linux上的剪贴板?
> x <- 1:10
> dput(x, 'clipboard')
Error in file(file, "wt") : 'mode' for the clipboard must be 'r' on Unix
我怎么能写到剪贴板/主选择?
请注意,我看过this old R-Help post,但我仍然不清楚我应该做什么。
Linux没有剪贴板,但X11会话具有主要和 次要选择。 ?文件说
剪贴板:
'file' can also be used with 'description = "clipboard"' in mode '"r"' only. It reads the X11 primary selection, which can also be specified as '"X11_primary"' and the secondary selection as '"X11_secondary"'. When the clipboard is opened for reading, the contents are immediately copied to internal storage in the connection. Unix users wishing to _write_ to the primary selection may be able to do so via 'xclip' (<URL: http://people.debian.org/~kims/xclip/>), for example by 'pipe("xclip -i", "w")'.
所以RTFM应用。写入X11选择需要多个线程 ,我并不认为它值得执行(与Windows不同)的非常大的努力。
请注意,窗口管理器可能有其他剪贴板,例如 RGtk2软件包具有接口到gtk剪贴板。
+1谢谢。我很感激。我仍然很想看看还有其他什么策略。我偶尔喜欢粘贴到剪贴板的主要原因是保存几秒钟,而不是写入文件并从文件中复制。上述策略似乎假设我可以提前预测我需要剪贴板。我也无法在R Studio中使用它。我只能让它和控制台一起工作。 –
@JeromyAnglim我也注意到这是一个RStudio问题,所以你最好向RStudio开发者报告。我不知道他们用剪贴板做了什么。 –
这对我来说并不适用于ubuntu,无论是在R Studio还是在R的终端版本中。我承认我没有完全阅读xclip的人(第2步),但我不认为应该会影响结果。 – geneorama