我正在運行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