How to solve “clipboard buffer is full and output lost” error in R running in Windows?

前端 未结 2 875
孤街浪徒
孤街浪徒 2021-01-30 22:49

I am trying to copy some data directly from R to the clipboard, in my Windows machine. I found in some sites that using file=\"clipboard\" would work. And it does, but for very

2条回答
  •  無奈伤痛
    2021-01-30 23:20

    If you type ?connections you will find your answer.

    This is the relevant part:

    "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."

    So, the solution is pretty straigthforward:

    df1 <- data.frame(x=runif(10000))
    write.table(df1, file="clipboard-16384", sep="\t", col.names=NA)
    

    Note that the number of Kb is just an example, so you can change it as you need (I put 2^14 that should be more than enough for your data set, but you can increase it even more. Not sure which is the hard limit, though. Maybe physical memory?)

提交回复
热议问题