reproducible example (reprex)
install once per computer
install.packages("reprex")
or part of `tidyverse
install.packages("tidyverse")
You can either call it in every session
library(reprex)
or put it in .Rprofile
for each machine to run whenever you open R
if (interactive()){
suppressMessages(require(reprex))
}
options(
reprex.advertise = FALSE,
reprex.si = TRUE,
reprex.style = TRUE,
reprex.comment = "#;-",
reprex.tidyverse_quiet = FALSE
)
to see your .Rprofile
usethis::edit_r_profile()
Since reprex
is an interactive workflow package, don’t use this with dplyr
, ggplot2
, etc.
When ever you want to ask people about your code, or ask them to debug it
- Copy your code to clipboard
- Simply run in your console
reprex()
reprex(advertise = TRUE, # To suppress ads
si = TRUE, # to include session info
style = TRUE, # restyle your code
tidyverse_quiet = TRUE # suppress tidyverse message
)
Or instead of doing it manually, you can select your code, and under “Addins”. select “Render reprex”