April 11, 2023

Clipr

write_clip copies data frames and R objects to your clipboard.

# install.packages("clipr")
library(clipr)

write_clip(iris %>% filter(Species == 'virginica'))

Reprex

The Reprex library is based on clipr and creates reproducible examples of R code which are copied to your clipboard. This can be used for troubleshooting and/or providing others w/context about your code on Github, Stack Overflow, and Slack.

Stack Overflow Minimal Reproducible Example (MRE):

The default markdown format (reprex()) is suitable for Github and Stack Overflow. It can be changed by modifying the ‘venue’ value to ‘slack’, ‘r’, ‘HTML’, and ‘rtf’. Note that this is case sensitive

  • ‘gh’ - GitHub-Flavored Markdown (default). ‘so’ (Stack Overflow markdown) & ‘ds’ (Discourse) produce the same output

  • ‘r’ - runnable R script

  • ‘html’ - HTML

  • ‘rtf’ - Rich Text Formatting

  • ‘slack’ - If you don’t use WYSIWYG, this will be helpful (Should be enabled by default.)

# install.packages("reprex")
library(reprex)

# reprex()
reprex(mean[1:100])

rmarkdown::render(reprex(mean[1], venue = 'r'))

rmarkdown::render(reprex(mean[1], venue = 'slack'))