write_cb | R Documentation |
These functions aim at providing portable way of reading and writing to system clipboard. The primary motivation was to smooth the process of copy-pasting computation results from R to Office programs (MSWord, LibreOffice, etc.).
write_cb(x, ...) read_cb(...)
x |
object to be written, it is coerced to character |
... |
other arguments passed to/from other methods, including |
Interaction with system clipboard is very much system-dependent. The
particular method used depends on the type of the operating system, which is
queried from Sys.info()["sysname"]
.
write_cb
expects a single argument which is written into the
clipboard after being converted to character. Writing is performed via a
connection description of which can be specified with condesc
or the
clipboard.write
option. Defaults are system-specific, see below.
On Windows writing to clipboard is performed via file
connection.
Default description is clipboard
.
On Unix-like systems a small program xclip
has to be installed, see
References below. Writing is performed via a pipe
with description
xclip -i -selection clipboard
. By default we are using X selection
clipboard
. Alternatives are XA_PRIMARY
or XA_SECONDARY
.
Consult further documentation of xclip
.
On MacOS writing is performed via pipe
using pbcopy
description
by default.
read_cb
can be called without any arguments. Reading is performed via
a connection description of which can be specified with condesc
or
clipboard.read
option. Defaults are system specific, see below.
Reading Windows clipboard uses file
connection with description clipboard
.
Reading clipboard on Linux is performed via a pipe
and xclip
program.
Reading clipboard on MacOS uses pipe
with description pbcopy
.
For write_cb
it is NULL
.
For read_cb
, it is a character vector with lines of content of the
clipboard.
Program xclip
http://sourceforge.net/projects/xclip
Section "Clipboard" of help(connection)
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.