简体   繁体   中英

R 4.2.0: write.table() "clipboard-1024" copies only columns name

I used write.table(mat, "clipboard-1024", sep="\t", row.names=FALSE) to copy from R to Excel in previous versions. After updating to 4.2.0 it copies columns names only to clipboard. Win 10 64 bit. Any ideas on how to fix it? Try this:

mat = matrix(0, 2, 3)
write.table(mat, "clipboard-1024", sep="\t", row.names=FALSE)

From Tomas Kalibera (Bugzilla) Thanks for the report and the nicely minimized example. Fixed in R-devel and will be ported to R-patched. The bug is in new clipboard code and affects any code doing subsequent writes to already opened clipboard connection. This is another repro for the same issue:

con <- file("clipboard")
open(con, "w")
cat("A", file=con)
cat("B", file=con)
close(con)
readLines("clipboard") # should be AB but instead A<garbage>

It only affects Windows because R supports writing to clipboard only on Windows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM