The format of the copied data is tab-delimited for pasting into a spreadsheet.
There are 2 ways to pass data into the function:
Type it out the same as any other function.
Highlight a data object in your RStudio text editor and then press key-chord:
ctrl + alt + shift + c
. (Use the quick keys just like you usectrl + c
for copying, except thatcopy_for_xl()
uses all 3 control keys plus the 'c'.
Details
To set up the key-chord in RStudio, use set_xlr_key_chords()
.
Copying formatted output to the clipboard requires package clipr
.
If using Linux, make sure to install a clipboard tool: apt-get install xclip or apt-get install xsel
copy_for_xl()
coerces the input data object to a tibble prior to copying to
clipboard.
Examples
if (FALSE) {
copy_for_xl(iris)
copy_for_xl(letters)
colours() |> copy_for_xl()
head(mtcars) |> copy_for_xl()
colours() |> rlang::set_names() |> entibble(another_col = colours()) |> copy_for_xl()
dplyr::bind_cols(letters, LETTERS) |> head() |> copy_for_xl()
rlang::set_names(letters, LETTERS) |> copy_for_xl()
# To use quick keys. Run {.fn set_xlr_key_chords}.
# Then highlight the word 'letters' below and press key-chord `ctrl + alt + shift + c`.
letters
}