clipr (version 0.4.1)

write_clip: Write clipboard

Description

Write a character vector to the system clipboard

Usage

write_clip(content, object_type = c("auto", "character", "table"),
  breaks = NULL, eos = NULL, return_new = TRUE, ...)

Arguments

content

An object to be written to the system clipboard.

object_type

write_clip() tries to be smart about writing objects in a useful manner. If passed a data.frame or matrix, it will format it using write.table for pasting into an external spreadsheet program. It will otherwise coerce the object to a character vector. auto will check the object type, otherwise table or character can be explicitly specified.

breaks

The separator to be used between each element of the character vector being written. NULL defaults to writing system-specific line breaks between each element of a character vector, or each row of a table.

eos

The terminator to be written after each string, followed by an ASCII nul. Defaults to no terminator character, indicated by NULL.

return_new

If true, returns the rendered string; if false, returns the original object

...

Custom options to be passed to write.table (if the object is a table-like) Defaults to sane line-break and tab standards based on the operating system.

Value

Invisibly returns the original object

Examples

Run this code
# NOT RUN {
text <- "Write to clipboard"
write_clip(text)

multiline <- c("Write", "to", "clipboard")
write_clip(multiline)
# Write
# to
# clipboard

write_clip(multiline, breaks = ",")
# write,to,clipboard

tbl <- data.frame(a=c(1,2,3), b=c(4,5,6))
write_clip(tbl)
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace