Linux 上的 Reprex 错误:未提供输入且剪贴板不可用

Reprex error on Linux: No input provided and clipboard is not available

无法在 Linux 上生成 reprex。当我尝试一个简单的例子时

  (y <- 1:4)
  mean(y)

我收到以下消息

No input provided and clipboard is not available.
Rendering reprex...
Clipboard on X11 requires 'xclip' (recommended) or 'xsel'.
Unable to put result on the clipboard. How to get it:
* Capture what `reprex()` returns.
* Consult the output file. Control via `outfile` argument.
Path to `outfile`:
    * /tmp/RtmpRYA93G/reprex16f2e48b49ed7/reprex_reprex.md
Open the output file for manual copy?
1: yes
2: no

以及我的查看器中的以下输出

 No user-supplied code found … so we’ve made some up. You’re welcome!

 sprintf("Happy %s!", weekdays(Sys.Date()))
 #> [1] "Happy Friday!"
 Created on 2020-10-16 by the reprex package (v0.3.0.9001)

是否是 Linux 上的剪贴板问题? 感谢您的帮助。

剪贴板在 Linux 上通常不可用,如果用户想要 运行 reprex,则必须安装 xclip。另一种方法是不使用 MrFlick 评论中建议的剪贴板

reprex::reprex({(y <- 1:4); mean(y)})