I am trying to use the write.table function to write to my clipboard on a mac os system. From other threads, I’ve tried
data <- rbind(c(1,1,2,3), c(1,1, 3, 4), c(1,4,6,7))
clip <- pipe("pbcopy", "w")
write.table(data, file="clip")
close(clip)
This code does not give any error messages, but also does not copy anything to the clipboard.
any suggestions?
I don’t have any machine under OS X to test it, but I think you should use just
clipinstead of"clip":Here
clipis an R object.If you pass a string “clip” to the
fileargument R will think it is a file name, and instead of finding your data in clipboard, you will find a file in you R session working directory called “clip” with your data inside.