writeClipboard for matrices or data frames?

前端 未结 3 944
借酒劲吻你
借酒劲吻你 2021-02-13 05:35

writeClipboard works for raw or character vectors. Is there anything that can let me place matrices/data.frames into the clipboard?

相关标签:
3条回答
  • 2021-02-13 06:14

    I think write.table with the file = "clipboard" argument will work. Here's an example:

    write.table(mtcars, "clipboard", sep="\t", row.names=FALSE)
    
    0 讨论(0)
  • 2021-02-13 06:20

    The above is mostly a wrong answer if your table is a little bigger.

    Warning message:
    In .External2(C_writetable, x, file, nrow(x), p, rnames, sep, eol,  :
      clipboard buffer is full and output lost
    

    The hack fix is this:

    writeClipboard(knitr::kable(d))
    
    0 讨论(0)
  • 2021-02-13 06:30

    A nice OS independent solution is:

    library(clipr)
    clipr::write_clip(mtcars)
    

    But may suffer from size limitations as well.

    0 讨论(0)
提交回复
热议问题