write_clipboard.data.frame: Write data frame to clipboard

View source: R/dataset_IO.R

write_clipboard.data.frameR Documentation

Write data frame to clipboard

Description

A wrapper function to write.table for writing to the clipboard for pasting in a spreadsheet.

Usage

## S3 method for class 'data.frame'
write_clipboard(
  x,
  digits = 2,
  clean_names = T,
  clean_what = c("_", "\\."),
  pad_digits = T,
  print = T,
  .rownames = T,
  write_to_clipboard = interactive(),
  return_modified = F,
  capitalize_dimnames = T,
  na = ""
)

Arguments

x

(any object that works with write.table) Something to write to the clipboard.

digits

(int scalar) A number of digits to round the data to.

clean_names

(log scalar) Whether to clean the names. Default=T.

clean_what

(chr vector) Which things to clean. Defaults to underscores and dots.

pad_digits

(log scalar) Whether to pad zeros to the digits (for prettier tables; default = T).

print

(log scalar) Whether to also print the output in R (default T).

.rownames

(lgl scalar) Whether to write rownames. Default yes. These are written to a column in front called .rownames.

write_to_clipboard

(lgl) Whether to write to the clipboard. Can be useful to disable in rare cases.

return_modified

(lgl) Whether to return the modified input instead of the original. Useful if one wants to modify it further.

capitalize_dimnames

(lgl) Whether to capitalize the first letter in the dimnames.

na

(chr) How to write NAs.

Examples

iris[-5] %>% cor() %>% write_clipboard()
iris %>% head() %>% miss_add_random() %>% write_clipboard()
#does not pad integers
test_df = data.frame(int = 1:5, num = rnorm(5))
test_df %>% write_clipboard()
#removes list columns
test_df$lc = list(1:3)
test_df %>% write_clipboard()

Deleetdk/kirkegaard documentation built on April 22, 2024, 5:22 p.m.