clipboard | R Documentation |
Wrappers for working with the clipboard
write_clipboard(x, ...)
## Default S3 method:
write_clipboard(x, ...)
## S3 method for class 'data.frame'
write_clipboard(x, sep = "\t", row.names = FALSE, ...)
## S3 method for class 'matrix'
write_clipboard(x, sep = "\t", ...)
## S3 method for class 'list'
write_clipboard(x, sep = "\t", ...)
read_clipboard(method = c("default", "data.frame", "tibble"), ...)
x |
An object |
... |
Additional arguments sent to methods or to |
sep |
the field separator string. Values within each row of
|
row.names |
either a logical value indicating whether the row
names of |
method |
Method switch for loading the clipboard |
As these functions rely on utils::readClipboard()
and
utils::writeClipboard()
they are only available for Windows 10. For copying
and pasting floats, there may be some rounding that can occur.
write_clipboard()
None, called for side effects read_clipboard()
Either a vector, data.frame
, or tibble
depending on the method
chosen.
Unlike utils::readClipboard()
, an empty clipboard value returns NA
rather
than ""
# Will only run on windows
if (Sys.info()[["sysname"]] == "Windows") {
foo <- function(x) {
write_clipboard(x)
y <- read_clipboard()
res <- all.equal(x, y)
if (isTRUE(res)) return("All equal")
print(x)
print(y)
}
foo(1:4)
foo(seq(-1, 1, .02))
foo(Sys.Date() + 1:4)
# May have some rounding issues
x <- "0.316362437326461129"
write_clipboard(x)
res <- as.character(read_clipboard())
all.equal(x, res)
x; res
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.