LoginSignup
4
2

More than 1 year has passed since last update.

Rからクリップボードに大きめのデータをコピーする方法

Last updated at Posted at 2018-04-18

RからExcelに手軽にデータをコピーしたい時、

write.table(sample_data, file = "clipboard", sep="\t")

が便利なわけですが、
コピーしたいデータのサイズが大きいと、以下のエラーが出ます。

clipboard buffer is full and output lost

対処として

write.table(sample_data, file = "clipboard-16384", sep="\t")

と書くと、16Mくらいまでであれば、コピー可能になります。(これ以上は無理のようです)

どういうことかと言いますと、
"clipboard-**" → **の部分で、クリップボードの容量最大値を指定できるようです。
詳しくは下記をご参照下さい。(というかこの記事は下記の和訳です。)
https://stackoverflow.com/questions/32035119/how-to-solve-clipboard-buffer-is-full-and-output-lost-error-in-r-running-in-wi

R上にも明記があって、
?connection でClipboardの項を見ると、
"When writing to the clipboard, the output is copied to the clipboard only when the connection is closed or flushed. There is a 32Kb limit on the text to be written to the clipboard. This can be raised by using e.g. file("clipboard-128") to give 128Kb."
とクリップボードの容量を変えられる記載があります。

よろしくお願いします。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2