For generic clipboard-reading in Mac, the syntax would be:
indat<-scan(pipe("pbpaste"),what=character(),...)
The ...
here is just a place-holder, look up the scan
help to see the very many options you have (the scan
default is to expect a double
variable in the what
argument; character
is probably safest for generic copy, or you can choose whatever is right for your case).
Similarly, for pasting into the Mac clipboard, the generic Mac syntax is
outdat<-"Hi There!"
cat(outdat, file=pipe("pbcopy","w"), ...)
Note that the nearly the same syntax should work in Windows and Linux as well; you should just replace the pipe
calls with the generic connection name "clipboard"
.
The Kmisc package function mentioned above only works for data frames and tabular data, not for generic copy/paste.