diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml index aa83eca..91cb7a7 100644 --- a/dev/pkgdown.yml +++ b/dev/pkgdown.yml @@ -8,7 +8,7 @@ articles: reprex-dos-and-donts: reprex-dos-and-donts.html articles/rtf: rtf.html articles/suppress-startup-messages: suppress-startup-messages.html -last_built: 2024-08-05T15:07Z +last_built: 2024-09-10T22:35Z urls: reference: https://reprex.tidyverse.org/reference article: https://reprex.tidyverse.org/articles diff --git a/dev/reference/reprex_document.html b/dev/reference/reprex_document.html index 8eaf091..91f9a8a 100644 --- a/dev/reference/reprex_document.html +++ b/dev/reference/reprex_document.html @@ -264,7 +264,7 @@

Examples#> { #> xfun::upload_imgur(file, key, ..., include_xml = TRUE) #> } -#> <bytecode: 0x565421193b08> +#> <bytecode: 0x55c5b00fc898> #> <environment: namespace:knitr> #> #> @@ -329,8 +329,8 @@

Examples#> } #> write_lines(input_lines, knit_input) #> } -#> <bytecode: 0x56541ee98770> -#> <environment: 0x565420e957a0> +#> <bytecode: 0x55c5ab1654a8> +#> <environment: 0x55c5afb32738> #> #> $post_knit #> NULL @@ -355,8 +355,8 @@

Examples#> if (is.function(overlay)) #> overlay() #> } -#> <bytecode: 0x565420f4f000> -#> <environment: 0x565420f50090> +#> <bytecode: 0x55c5adc22448> +#> <environment: 0x55c5adc22a30> #> #> attr(,"class") #> [1] "rmarkdown_output_format" diff --git a/dev/search.json b/dev/search.json index f9c0034..1e8b68b 100644 --- a/dev/search.json +++ b/dev/search.json @@ -1 +1 @@ -[{"path":[]},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://reprex.tidyverse.org/dev/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to reprex","title":"Contributing to reprex","text":"outlines propose change reprex. detailed info contributing , tidyverse packages, please see development contributing guide.","code":""},{"path":"https://reprex.tidyverse.org/dev/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to reprex","text":"Small typos grammatical errors documentation may edited directly using GitHub web interface, long changes made source file. YES: edit roxygen comment .R file R/. : edit .Rd file man/.","code":""},{"path":"https://reprex.tidyverse.org/dev/CONTRIBUTING.html","id":"prerequisites","dir":"","previous_headings":"","what":"Prerequisites","title":"Contributing to reprex","text":"make substantial pull request, always file issue make sure someone team agrees ’s problem. ’ve found bug, create associated issue illustrate bug minimal reprex.","code":""},{"path":"https://reprex.tidyverse.org/dev/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"","what":"Pull request process","title":"Contributing to reprex","text":"recommend create Git branch pull request (PR). Look Travis AppVeyor build status making changes. README contain badges continuous integration services used package. New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat. Contributions test cases included easier accept. user-facing changes, add bullet top NEWS.md current development version header describing changes made followed GitHub username, links relevant issue(s)/PR(s).","code":""},{"path":"https://reprex.tidyverse.org/dev/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to reprex","text":"Please note project released Contributor Code Conduct. participating project agree abide terms.","code":""},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 reprex authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://reprex.tidyverse.org/dev/SUPPORT.html","id":null,"dir":"","previous_headings":"","what":"Getting help with reprex","title":"Getting help with reprex","text":"Thanks using reprex. filing issue, places explore pieces put together make process smooth possible. Start making minimal reproducible example using reprex package. OK, ’s funny, package ’re talking ! best provide input, reprex() call, expected result, actual result. Make easy reproduce problem. additional reprex pointers, check Get help! section tidyverse site. Armed reprex, next step figure ask. ’s question: start community.rstudio.com, /StackOverflow. people answer questions. ’s bug: ’re right place, file issue. ’re sure: let community help figure ! problem bug feature request, can easily return report . opening new issue, sure search issues pull requests make sure bug hasn’t reported /already fixed development version. default, search pre-populated :issue :open. can edit qualifiers (e.g. :pr, :closed) needed. example, ’d simply remove :open search issues repo, open closed. right place, need file issue, please review “File issues” paragraph tidyverse contributing guidelines. Thanks help!","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/datapasta-reprex.html","id":"scenario-1-from-spreadsheet-to-reprex-with-tribble_paste","dir":"Articles","previous_headings":"","what":"Scenario 1: From spreadsheet to reprex with tribble_paste()","title":"Using datapasta with reprex","text":"’s easy copy paste nicely formatted data spreadsheet datapasta’s tribble_paste() functionality. ’ve found simplest method : Copy data source onto clipboard. Click Paste tribble datapasta section RStudio Addins drop-. sure assign data frame name, can use elsewhere reprex. datapasta::tribble_paste() output tribble_paste() doesn’t level detail dput(), works well enough scenarios, added benefit easy read screen.","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/datapasta-reprex.html","id":"scenario-2-from-r-object-to-tibble-with-dpasta","dir":"Articles","previous_headings":"","what":"Scenario 2: From R object to tibble with dpasta()","title":"Using datapasta with reprex","text":"Now let’s say data frame R want use reprex. can use datapasta’s dpasta() function render object format result tribble_paste(), . datapasta::dpasta()","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/datapasta-reprex.html","id":"fin","dir":"Articles","previous_headings":"","what":"Fin","title":"Using datapasta with reprex","text":"’s datapasta discussed , sure check documentation. Don’t forget, comes reprex, less always , wield power datapasta wisely.","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/learn-reprex.html","id":"help-me-help-you-creating-reproducible-examples-with-reprex","dir":"Articles","previous_headings":"","what":"Help me help you: Creating reproducible examples with reprex","title":"How to use reprex","text":"reprex? ’s reproducible example. Making great reprex art science webinar cover aspects. reprex makes conversation code efficient pleasant . comes whenever ask someone help, report bug software, propose new feature. reprex package (https://reprex.tidyverse.org) makes especially easy prepare R code reprex, order share sites https://community.rstudio.com, https://github.com, https://stackoverflow.com. habit making little, rigorous, self-contained examples also great side effect making think clearly programming problems. Webinar page: https://resources.rstudio.com/webinars/help--help--creating-reproducible-examples-jenny-bryan Slides SpeakerDeck: https://speakerdeck.com/jennybc/reprex-reproducible-examples--r","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/reprex-dos-and-donts.html","id":"main-requirements","dir":"Articles","previous_headings":"","what":"Main requirements","title":"Reprex do's and don'ts","text":"Use smallest, simplest, built-data possible. Think: iris mtcars. Bore . must make objects, minimize size complexity. Many functions packages already use offer way create small data frame “inline”: read.table() friends text argument. Example: tibble::tribble() lets use natural readable layout. Example: Get just bit something head() indexing result sample(). anything random, consider using set.seed() make repeatable. datapasta package can generate code data.frame(), tibble::tribble(), data.table::data.table() based existing R data frame. example, call tribble_format(head(ChickWeight, 3)) leaves clipboard, ready paste reprex: dput() decent last resort, .e. simply make built-simulated data inline data creation readable format. dput() output human-readable. Avoid possible. Look official examples try write style. Consider adapting one. Include commands strict “need run” basis. Ruthlessly strip anything unrelated specific matter hand. Include every single command required, e.g. loading specific packages via library(foo). Consider including -called “session info”, .e. OS versions R add-packages, ’s conceivable matters. Use reprex(..., session_info = TRUE) . Whitespace rationing effect. Use good coding style. Use reprex(..., style = TRUE) request automated styling code. Pack , pack , don’t take liberties people’s computers. asking people run code! Don’t start rm(list = ls()). anti-social clobber people’s workspaces. Don’t start setwd(\"C:\\Users\\jenny\\path\\\\\\\\\"), won’t work anyone else’s computer. Don’t mask built-functions, .e. don’t define new function named c mean. change options, store original values start, thing, restore : create files, delete ’re done: Don’t delete files objects didn’t create first place. Take advantage R’s built-ability create temporary files directories. Read tempfile() tempdir().","code":"read.csv(text = \"a,b\\n1,2\\n3,4\") #> a b #> 1 1 2 #> 2 3 4 tibble::tribble( ~ a, ~ b, 1, 2, 3, 4 ) #> # A tibble: 2 x 2 #> a b #> #> 1 1 2 #> 2 3 4 tibble::tribble( ~weight, ~Time, ~Chick, ~Diet, 42, 0, \"1\", \"1\", 51, 2, \"1\", \"1\", 59, 4, \"1\", \"1\" ) opar <- par(pch = 19) par(opar) write(x, \"foo.txt\") file.remove(\"foo.txt\")"},{"path":"https://reprex.tidyverse.org/dev/articles/reprex-dos-and-donts.html","id":"this-seems-like-a-lot-of-work","dir":"Articles","previous_headings":"","what":"This seems like a lot of work!","title":"Reprex do's and don'ts","text":"Yes, creating great reprex requires work. asking people work . ’s partnership. 80% time solve problem course writing excellent reprex. YMMV. remaining 20% time, create reprex likely elicit desired behavior others.","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/reprex-dos-and-donts.html","id":"further-reading","dir":"Articles","previous_headings":"","what":"Further reading:","title":"Reprex do's and don'ts","text":"make great R reproducible example? thread StackOverflow","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/reprex-dos-and-donts.html","id":"package-philosophy","dir":"Articles","previous_headings":"","what":"Package philosophy","title":"Reprex do's and don'ts","text":"reprex code: Must run , therefore, run person posting. faking . easy others digest, don’t necessarily run . encouraged include selected bits output. :scream: easy others copy + paste + run, choose. Don’t let inclusion output break executability. Accomplished like : Use rmarkdown::render() run code capture output normally see screen. done separate R process, via callr, guarantee self-contained. Use chunk option comment = \"#>\" include output retaining executability.","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"how-to-install-highlight","dir":"Articles","previous_headings":"","what":"How to install highlight","title":"reprex venue RTF","text":"highlight website offers downloads various forms, various OSes: http://www.andre-simon.de/zip/download.php macOS users use homebrew, works: Windows users use chocolatey, works: Windows, chocolatey method add highlight PATH affect methods installation well. case, ’ll need manually. case, needed add C:\\Program Files\\Highlight PATH. second issue ’ve seen scoop package manager Windows, uses shim-based method making executables installs findable. shim method appears less resilient different ways calling highlight R. reprex_rtf() work Sys.(\"highlight\"), executed R, correctly returns path highlight executable. ’s looks macOS: Windows: highlight call implied default behaviour reprex_rtf():","code":"brew install highlight choco install highlight Sys.which(\"highlight\") #> highlight #> \"/usr/local/bin/highlight\" Sys.which(\"highlight\") #> highlight #> \"C:\\\\PROGRA~1\\\\HIGHLI~1\\\\HIGHLI~2.EXE\" highlight -i foo_reprex.R --out-format rtf --no-trailing-nl --encoding=UTF-8 --style darkbone --font 'Courier Regular' --font-size 50 -o foo_reprex.rtf"},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"basic-usage","dir":"Articles","previous_headings":"","what":"Basic usage","title":"reprex venue RTF","text":"Let’s reprex code stick Keynote slide non-R “features”.","code":"reprex({ (x <- rnorm(3)) mean(x) }, venue = \"rtf\")"},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"highlight-options","dir":"Articles","previous_headings":"","what":"highlight options","title":"reprex venue RTF","text":"don’t like defaults, control highlight command line arguments setting reprex.highlight.* options. options? didn’t want burden reprex() even arguments usually something want set globally entire project talk course. Set options code like : supported options reprex.highlight.hl_style, reprex.highlight.font, reprex.highlight.font_size (shown ), reprex.highlight.(catchall anything else, shown ). set options reprexing user-level .Rprofile. Create open file via usethis::edit_r_profile(). also set options specific Project .Rprofile inside Project. Create open file via usethis::edit_r_profile(\"project\"). Finally, might collect R snippets destined inclusion , e.g. talk slides, .R file. make sense set reprex.highlight.* options start file. hl_style must one existing highlight themes font must one installed fonts. List available themes: themes look like? galleries probably high overlap themes: http://www.andre-simon.de/doku/highlight/en/theme-samples.phphttps://rclickhandbuch.files.wordpress.com/2014/09/knitrthemesoverview.pdf can also override defaults --fly. ’s single call using withr , bonus, use reprex.highlight.send arbitrary command line arguments highlight: ’s set highlight options part R session: Experience shown hard predict aspects RTF honored paste target document. ’re talking things like font size background color. seems vary greatly across applications operating systems ’ll just experiment find workflow practical . Note even possible create custom highlight theme, e.g. match theme Keynote Powerpoint slide deck respect background color, font, etc. specific example documented -notes.","code":"options( reprex.highlight.hl_style = \"darkbone\", reprex.highlight.font = \"Source Code Pro\", reprex.highlight.font_size = 50 ) highlight --list-scripts=themes withr::with_options( new = c( reprex.highlight.hl_style = \"dusk\", reprex.highlight.font = \"Fira Code Regular\", reprex.highlight.font_size = 35, reprex.highlight.other = \"--line-numbers --line-number-length=2 --zeroes\" ), reprex::reprex(input = c(\"(x <- rnorm(3))\", \"mean(x)\"), venue = \"rtf\") ) op <- options( reprex.highlight.hl_style = \"anotherdark\", reprex.highlight.font = \"Andale Mono Regular\", reprex.highlight.font_size = 60, reprex.highlight.other = \"--line-numbers\" ) reprex::reprex(input = c(\"(x <- rnorm(3))\", \"mean(x)\"), venue = \"rtf\") options(op)"},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"run-or-not","dir":"Articles","previous_headings":"","what":"Run … or not","title":"reprex venue RTF","text":"just want highlight code, run , set chunk option eval = FALSE option, .e. put special comment first line reprex source: source, reprex()ed, include usual output. specific venue = \"rtf\", ’s likely come setting.","code":"#+ eval = FALSE (x <- rnorm(3)) mean(x)"},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"reprexprex-and-friends","dir":"Articles","previous_headings":"What if each snippet can’t be self-contained?","what":"reprex:::prex() and friends","title":"reprex venue RTF","text":"preparing bits code presentation, can impractical make snippet completely self-contained. really need run snippets current workspace session. reprex() allow . unexported function prex() addresses use case. ’s like reprex(), much less reproducible! Code evaluated global environment current R session. Current working directory used. advertise = FALSE default. prex() also “venue suffix” variants, reprex:::prex_rtf(...) short reprex:::prex(..., venue = \"rtf\"). code defines x y current workspace writes file stuff.txt current working directory. Now can show difference prex() reprex(). yields x y can found, even though aren’t defined snippet, stuff.txt can read. different executing code via reprex(): yields: x y can’t found, reprex() works clean session, stuff.txt can’t found, reprex() works temp directory, default. ’re going prex() lot, ’ll want something like .R file snippets project-specific user-level .Rprofile:","code":"x <- 1 y <- 4 writeLines(\"blah blah\", file.path(getwd(), \"stuff.txt\")) prex({ ls() x + y readLines(\"stuff.txt\") }) ls() #> [1] \"x\" \"y\" x + y #> [1] 5 readLines(\"stuff.txt\") #> [1] \"blah blah\" reprex({ ls() x + y readLines(\"stuff.txt\") }) ls() #> character(0) x + y #> Error in eval(expr, envir, enclos): object 'x' not found readLines(\"stuff.txt\") #> Warning in file(con, \"r\"): cannot open file 'stuff.txt': No such file or #> directory #> Error in file(con, \"r\"): cannot open the connection prex <- reprex:::prex prex_rtf <- reprex:::prex_rtf"},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"selectively-hide-and-reveal-code","dir":"Articles","previous_headings":"","what":"Selectively hide and reveal code","title":"reprex venue RTF","text":"prex() existed, use cumbersome technique produce small snippets, hiding code. leave case still useful situations. can use knitr chunk options selectively hide code, .e. run large snippet, include small bit output. easiest show example. reprex() code, last three lines output appear output. lines run, .e. str_reverse() defined, bizzaro() generic default method.","code":"#+ include = FALSE str_reverse <- function(x) { vapply( strsplit(x, \"\"), FUN = function(z) paste(rev(z), collapse = \"\"), FUN.VALUE = \"\") } #+ include = FALSE bizarro <- function(x) { UseMethod(\"bizarro\") } bizarro.default <- function(x) { stop( \"Don't know how to make bizzaro <\", class(x)[[1]], \">\", call. = FALSE ) } #+ include = TRUE bizarro.character <- function(x) str_reverse(x) bizarro(c(\"abc\", \"def\")) bizarro(1:5)"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"tldr","dir":"Articles","previous_headings":"","what":"TL;DR","title":"Suppress package startup messages","text":"’s quick look various techniques. described detail . Call library() warn.conflicts = FALSE. Surround chatty library() call suppressPackageStartupMessages(). Break reprex “chunks”, .Rmd sense, use special #+ comment silence messages /warnings chunk holds chatty library() call. Note second #+ comment important, don’t silence messages warnings entire reprex. ’re using one tidyverse packages, consider using tidyverse metapackage, literally. reprex::reprex() argument tidyverse_quiet, defaults TRUE silences startup messages. tidyverse_quiet also silences startup messages tidymodels meta-package.","code":"library(dplyr, warn.conflicts = FALSE) suppressPackageStartupMessages(library(dplyr)) #+ message = FALSE, warning = FALSE library(dplyr) #+ slice(iris, 1) library(tidyverse) slice(iris, 1)"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"dplyr-is-chatty-at-startup","dir":"Articles","previous_headings":"","what":"dplyr is chatty at startup","title":"Suppress package startup messages","text":"dplyr common culprit noisy startup, use example. Note messaging baseline.","code":"library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"warn-conflicts-false","dir":"Articles","previous_headings":"","what":"warn.conflicts = FALSE","title":"Suppress package startup messages","text":"suppress warnings conflicts, set warn.conflicts argument library() FALSE.","code":"library(dplyr, warn.conflicts = FALSE) slice(iris, 1) #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"suppresspackagestartupmessages","dir":"Articles","previous_headings":"","what":"suppressPackageStartupMessages()","title":"Suppress package startup messages","text":"Surround library() suppressPackageStartupMessages().","code":"suppressPackageStartupMessages(library(dplyr)) slice(iris, 1) #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"set-message-false-and-warning-false-for-a-chunk","dir":"Articles","previous_headings":"","what":"Set message = FALSE and warning = FALSE for a chunk","title":"Suppress package startup messages","text":"working R Markdown, suppress messages warnings chunk containing library() calls, put “real code” different chunk: can plain R code, suitable reprex()ing, using special comments start #+. Note second #+ significant, begins new chunk capable emitting messages warnings.","code":"```{r, message = FALSE, warning = FALSE} library(dplyr) ``` Some text. ```{r} slice(iris, 1) ``` #+ message = FALSE, warning = FALSE library(dplyr) message(\"You CANNOT hear me!\") #+ message(\"You can hear me!\") slice(iris, 1)"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"reprex-knows-about-tidyverse_quiet","dir":"Articles","previous_headings":"","what":"reprex knows about tidyverse_quiet","title":"Suppress package startup messages","text":"reprex::reprex() function tidyverse_quiet argument defaults TRUE. reprex uses one tidyverse packages, consider attaching tidyverse metapackage, instead individual packages, order enjoy quiet startup. Note default behaviour can overridden setting tidyverse_quiet = FALSE specific reprex() call setting option reprex.tidyverse_quiet = FALSE .Rprofile startup file. tidyverse_quiet argument reprex.tidyverse_quiet option also affect startup messages tidymodels meta-package.","code":"library(tidyverse) # instead of library(dplyr) slice(iris, 1) #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa"},{"path":"https://reprex.tidyverse.org/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Jennifer Bryan. Author, maintainer. Jim Hester. Author. David Robinson. Author. Hadley Wickham. Author. Christophe Dervieux. Author. . Copyright holder, funder.","code":""},{"path":"https://reprex.tidyverse.org/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Bryan J, Hester J, Robinson D, Wickham H, Dervieux C (2024). reprex: Prepare Reproducible Example Code via Clipboard. R package version 2.1.1.9000, https://github.com/tidyverse/reprex, https://reprex.tidyverse.org.","code":"@Manual{, title = {reprex: Prepare Reproducible Example Code via the Clipboard}, author = {Jennifer Bryan and Jim Hester and David Robinson and Hadley Wickham and Christophe Dervieux}, year = {2024}, note = {R package version 2.1.1.9000, https://github.com/tidyverse/reprex}, url = {https://reprex.tidyverse.org}, }"},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"Prepare Reproducible Example Code via the Clipboard","text":"Prepare reprexes posting GitHub issues, StackOverflow, Slack messages snippets, even paste PowerPoint Keynote slides. reprex? ’s reproducible example, coined Romain Francois tweet 2014. Given R code clipboard, selected RStudio, expression (quoted ), file … run via rmarkdown::render(), deliberate choices re: render() arguments, knitr options, Pandoc options. Get resulting runnable code + output Markdown, suitable GitHub Stack Overflow Slack, R code, augmented commented output, Plain HTML (experimental) Rich Text result returned invisibly, written file , possible, placed clipboard. Preview HTML version RStudio viewer default browser.","code":""},{"path":"https://reprex.tidyverse.org/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Prepare Reproducible Example Code via the Clipboard","text":"Install CRAN: get development version GitHub: Linux, probably want install xclip xsel, reprex can access X11 clipboard. ‘nice ’, mandatory. usual sudo apt-get install sudo yum install installation methods work xclip xsel.","code":"install.packages(\"reprex\") # install.packages(\"pak\") pak::pak(\"tidyverse/reprex\")"},{"path":"https://reprex.tidyverse.org/dev/index.html","id":"usage","dir":"","previous_headings":"","what":"Usage","title":"Prepare Reproducible Example Code via the Clipboard","text":"Let’s say copy code onto clipboard (, RStudio Server Cloud, select ): call reprex(), default target venue GitHub: nicely rendered HTML preview display RStudio’s Viewer (’re RStudio) default browser otherwise. relevant bit GitHub-flavored Markdown ready pasted clipboard (RStudio Server Cloud, need copy ): ’s Markdown look like rendered GitHub issue: Anyone else can copy, paste, run immediately. addition GitHub, Markdown also works Stack Overflow Discourse. venues can formally requested via venue = \"\" venue = \"ds\", just aliases venue = \"gh\". Instead reading clipboard, can: reprex(mean(rnorm(10))) get code expression. reprex(input = \"mean(rnorm(10))\\n\") gets code character vector (detected via length terminating newline). Leading prompts stripped input source: reprex(input = \"> median(1:3)\\n\") produces output reprex(input = \"median(1:3)\\n\") reprex(input = \"my_reprex.R\") gets code file Use one RStudio add-ins use selected text current file. wait, ’s ! Get slightly different Markdown, optimized Slack messages, reprex(..., venue = \"slack\"). Get runnable R script, augmented commented output, reprex(..., venue = \"R\"). useful Slack code snippets, email, etc. Get html reprex(..., venue = \"html\"). Useful sites don’t support Markdown. Prepare (un)rendered, syntax-highlighted code snippets paste Keynote PowerPoint, reprex(..., venue = \"rtf\"). feature still experimental; see associated article . default, figures uploaded imgur.com resulting URL dropped inline image tag. really need reprex specific directory, use wd argument. example, reprex(wd = \".\") requests current working directory. Append session info via reprex(..., session_info = TRUE). Get clean, runnable code wild-caught reprexes reprex_invert() = opposite reprex() reprex_clean(), e.g. copy/paste GitHub Stack Overflow reprex_rescue(), ’re dealing copy/paste R Console","code":"(y <- 1:4) mean(y) reprex() ``` r (y <- 1:4) #> [1] 1 2 3 4 mean(y) #> [1] 2.5 ``` (y <- 1:4) #> [1] 1 2 3 4 mean(y) #> [1] 2.5"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex-package.html","id":null,"dir":"Reference","previous_headings":"","what":"reprex: Prepare Reproducible Example Code via the Clipboard — reprex-package","title":"reprex: Prepare Reproducible Example Code via the Clipboard — reprex-package","text":"Convenience wrapper uses 'rmarkdown' package render small snippets code target formats include code output. goal encourage sharing small, reproducible, runnable examples code-oriented websites, https://stackoverflow.com https://github.com, email. user's clipboard default source input code default target rendered output. 'reprex' also extracts clean, runnable R code various common formats, copy/paste R session.","code":""},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/reference/reprex-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"reprex: Prepare Reproducible Example Code via the Clipboard — reprex-package","text":"Maintainer: Jennifer Bryan jenny@posit.co (ORCID) Authors: Jim Hester (ORCID) David Robinson admiral.david@gmail.com Hadley Wickham hadley@posit.co (ORCID) Christophe Dervieux cderv@posit.co (ORCID) contributors: Posit Software, PBC [copyright holder, funder]","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a reprex — reprex","title":"Render a reprex — reprex","text":"Run bit R code using rmarkdown::render() write rendered result user's clipboard. clipboard unavailable, file containing rendered result opened manual copy. goal make easy share small reproducible example (\"reprex\"), e.g., GitHub issue. Reprex source can read clipboard provided directly expression, character vector, string read file read current selection active document RStudio reprex can also used syntax highlighting (without rendering); see .","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a reprex — reprex","text":"","code":"reprex( x = NULL, input = NULL, wd = NULL, venue = c(\"gh\", \"r\", \"rtf\", \"html\", \"slack\", \"so\", \"ds\"), render = TRUE, advertise = NULL, session_info = opt(FALSE), style = opt(FALSE), comment = opt(\"#>\"), tidyverse_quiet = opt(TRUE), std_out_err = opt(FALSE), html_preview = opt(TRUE), outfile = deprecated(), show = deprecated(), si = deprecated() )"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a reprex — reprex","text":"x expression. given, reprex() looks code input. input provided, reprex() looks clipboard. clipboard structurally unavailable, e.g., RStudio Server RStudio Cloud, reprex() consults current selection instead clipboard. input Character. length one lacks terminating newline, interpreted path file containing reprex code. Otherwise, assumed hold reprex code character vector. input specifies filepath, also determines reprex working directory location resulting files. wd optional filepath consulted input filepath. (default, work done, quietly, subdirectory session temp directory.) common use wd set wd = \".\", means \"reprex right current working directory\". really must demonstrate something local files. venue Character. Must one following (case insensitive): \"gh\" GitHub-Flavored Markdown, default \"r\" runnable R script, commented output interleaved. Also useful Slack code snippets; select \"R\" \"Type\" drop-menu enjoy nice syntax highlighting. \"rtf\" Rich Text Format (supported un-reprexing) \"html\" HTML fragment suitable inclusion larger HTML document (supported un-reprexing) \"slack\" pasting Slack message. Optimized people opt Slack's WYSIWYG interface. Go Preferences > Advanced > Input options select \"Format messages markup\". (demand second Slack venue optimized use WYSIWYG, please open issue discuss.) \"\" Stack Overflow Markdown. Note: just alias \"gh\", since Stack Overflow started support CommonMark-style fenced code blocks January 2019. \"ds\" Discourse, e.g., forum.posit.co. Note: currently just alias \"gh\". render Logical. Whether call rmarkdown::render() templated reprex, .e. whether actually run code. Defaults TRUE. Exists primarily sake internal testing. advertise Logical. Whether include footer describes reprex created. unspecified, option reprex.advertise consulted , defined, default TRUE venues \"gh\", \"html\", \"\", \"ds\" FALSE \"r\", \"rtf\", \"slack\". session_info Logical. Whether include sessioninfo::session_info(), available, sessionInfo() end reprex. venue \"gh\", session info wrapped collapsible details tag. Read opt(). style Logical. Whether set knitr chunk option tidy = \"styler\", re-styles code styler package. Read opt(). comment Character. Prefix comment output, defaults \"#>\". Read opt(). tidyverse_quiet Logical. Sets options tidyverse.quiet tidymodels.quiet, suppress (TRUE, default) include (FALSE) startup messages tidyverse tidymodels packages. Read opt(). std_out_err Logical. Whether append section output sent stdout stderr reprex rendering process. can necessary reveal output reprex spawns child processes system() calls. Note properly interleaved output main R process, guarantee lines standard output standard error correct chronological order. See callr::r() . Read opt(). html_preview Logical. Whether show rendered output viewer (RStudio browser). Always FALSE noninteractive session. Read opt(). outfile favor wd providing filepath input. reprex current working directory, use wd = \".\" now, instead outfile = NA. show favor html_preview, greater consistency R Markdown output formats. si favor session_info.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a reprex — reprex","text":"Character vector rendered reprex, invisibly.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Render a reprex — reprex","text":"usual \"code + commented output\" returned invisibly, written file, , whenever possible, put clipboard. HTML preview displays RStudio's Viewer pane, available, default browser, otherwise. Leading \"> \" prompts, stripped input code. Read https://reprex.tidyverse.org/. reprex sets specific knitr options: Chunk options default collapse = TRUE, comment = \"#>\", error = TRUE. Note error = TRUE, common use case bug reporting. reprex also sets knitr's upload.fun. defaults knitr::imgur_upload() figures produced reprex appear properly GitHub, Stack Overflow, Discourse, Slack. Note imgur_upload() requires packages httr xml2. venue = \"r\", upload.fun set identity(), figures remain local. case, may also want provide filepath input set wd, control reprex files written. can supplement override options special comments code (see examples).","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"error-backtraces","dir":"Reference","previous_headings":"","what":"Error backtraces","title":"Render a reprex — reprex","text":"use rlang::last_error() rlang::last_trace() within reprex, must place different \"chunk\" code generates error. easiest way insert line containing special comment #' error-causing code: Read rlang's documentation: Errors RMarkdown.","code":"f <- function() rlang::abort('foo') f() #' rlang::last_error() rlang::last_trace()"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"syntax-highlighting","dir":"Reference","previous_headings":"","what":"Syntax highlighting","title":"Render a reprex — reprex","text":"secondary use case reprex produce syntax highlighted code snippets, without rendering, paste applications like Microsoft Word, PowerPoint, Keynote. Use venue = \"rtf\" . feature experimental requires installation highlight command line tool. \"rtf\" venue documented article","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render a reprex — reprex","text":"","code":"if (FALSE) { # \\dontrun{ # put some code like this on the clipboard # (y <- 1:4) # mean(y) reprex() # provide code as an expression reprex(rbinom(3, size = 10, prob = 0.5)) reprex({y <- 1:4; mean(y)}) reprex({y <- 1:4; mean(y)}, style = TRUE) # note that you can include newlines in those brackets # in fact, that is often a good idea reprex({ x <- 1:4 y <- 2:5 x + y }) ## provide code via character vector reprex(input = c(\"x <- 1:4\", \"y <- 2:5\", \"x + y\")) ## if just one line, terminate with '\\n' reprex(input = \"rnorm(3)\\n\") ## customize the output comment prefix reprex(rbinom(3, size = 10, prob = 0.5), comment = \"#;-)\") # override a default chunk option reprex({ #+ setup, include = FALSE knitr::opts_chunk$set(collapse = FALSE) #+ actual-reprex-code (y <- 1:4) median(y) }) # add prose, use general markdown formatting reprex({ #' # A Big Heading #' #' Look at my cute example. I love the #' [reprex](https://github.com/tidyverse/reprex#readme) package! y <- 1:4 mean(y) }, advertise = FALSE) # read reprex from file and write resulting files to that location tmp <- file.path(tempdir(), \"foofy.R\") writeLines(c(\"x <- 1:4\", \"mean(x)\"), tmp) reprex(input = tmp) list.files(dirname(tmp), pattern = \"foofy\") # clean up file.remove(list.files(dirname(tmp), pattern = \"foofy\", full.names = TRUE)) # write reprex to file AND keep figure local too, i.e. don't post to imgur tmp <- file.path(tempdir(), \"foofy\") dir.create(tmp) reprex({ #+ setup, include = FALSE knitr::opts_knit$set(upload.fun = identity) #+ actual-reprex-code #' Some prose ## regular comment (x <- 1:4) median(x) plot(x) }, wd = tmp) list.files(dirname(tmp), pattern = \"foofy\") # clean up unlink(tmp, recursive = TRUE) ## target venue = R, also good for email or Slack snippets ret <- reprex({ x <- 1:4 y <- 2:5 x + y }, venue = \"R\") ret ## target venue = html ret <- reprex({ x <- 1:4 y <- 2:5 x + y }, venue = \"html\") ret ## include prompt and don't comment the output ## use this when you want to make your code hard to execute :) reprex({ #+ setup, include = FALSE knitr::opts_chunk$set(comment = NA, prompt = TRUE) #+ actual-reprex-code x <- 1:4 y <- 2:5 x + y }) ## leading prompts are stripped from source reprex(input = c(\"> x <- 1:3\", \"> median(x)\")) } # }"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_addin.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a reprex, conveniently — reprex_addin","title":"Render a reprex, conveniently — reprex_addin","text":"reprex_addin() opens RStudio gadget addin allows say reprex source (clipboard? current selection? active file? file?) control arguments. Appears \"Render reprex\" RStudio Addins menu. reprex_selection() addin reprexes current selection, optionally customised options. Appears \"Reprex selection\" RStudio Addins menu. Heavy users might want create keyboard shortcut. Suggested shortcut: Cmd + Shift + R (macOS) Ctrl + Shift + R (Windows).","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_addin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a reprex, conveniently — reprex_addin","text":"","code":"reprex_addin() reprex_selection(venue = getOption(\"reprex.venue\", \"gh\"))"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_addin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a reprex, conveniently — reprex_addin","text":"venue Character. Must one following (case insensitive): \"gh\" GitHub-Flavored Markdown, default \"r\" runnable R script, commented output interleaved. Also useful Slack code snippets; select \"R\" \"Type\" drop-menu enjoy nice syntax highlighting. \"rtf\" Rich Text Format (supported un-reprexing) \"html\" HTML fragment suitable inclusion larger HTML document (supported un-reprexing) \"slack\" pasting Slack message. Optimized people opt Slack's WYSIWYG interface. Go Preferences > Advanced > Input options select \"Format messages markup\". (demand second Slack venue optimized use WYSIWYG, please open issue discuss.) \"\" Stack Overflow Markdown. Note: just alias \"gh\", since Stack Overflow started support CommonMark-style fenced code blocks January 2019. \"ds\" Discourse, e.g., forum.posit.co. Note: currently just alias \"gh\".","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_document.html","id":null,"dir":"Reference","previous_headings":"","what":"reprex output format — reprex_document","title":"reprex output format — reprex_document","text":"R Markdown output format designed specifically making \"reprexes\", typically created via reprex() function, ultimately renders document reprex_render(). heavily modified version rmarkdown::md_document(). arguments different spheres influence: venue potentially affects input preparation reprex_render(). Add content primary input, prior rendering: advertise session_info std_out_err (also consulted reprex_render()) Influence knitr package chunk options: style comment tidyverse_quiet RStudio users can create new R Markdown documents reprex_document() format using built-templates. File > New File > R Markdown ... > Template choose one : reprex (minimal) reprex (lots features) include knit: reprex::reprex_render YAML, causes RStudio \"Knit\" button use reprex_render(). render documents , .","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_document.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"reprex output format — reprex_document","text":"","code":"reprex_document( venue = c(\"gh\", \"r\", \"rtf\", \"html\", \"slack\", \"so\", \"ds\"), advertise = NULL, session_info = opt(FALSE), style = opt(FALSE), comment = opt(\"#>\"), tidyverse_quiet = opt(TRUE), std_out_err = opt(FALSE), pandoc_args = NULL )"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_document.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"reprex output format — reprex_document","text":"venue Character. Must one following (case insensitive): \"gh\" GitHub-Flavored Markdown, default \"r\" runnable R script, commented output interleaved. Also useful Slack code snippets; select \"R\" \"Type\" drop-menu enjoy nice syntax highlighting. \"rtf\" Rich Text Format (supported un-reprexing) \"html\" HTML fragment suitable inclusion larger HTML document (supported un-reprexing) \"slack\" pasting Slack message. Optimized people opt Slack's WYSIWYG interface. Go Preferences > Advanced > Input options select \"Format messages markup\". (demand second Slack venue optimized use WYSIWYG, please open issue discuss.) \"\" Stack Overflow Markdown. Note: just alias \"gh\", since Stack Overflow started support CommonMark-style fenced code blocks January 2019. \"ds\" Discourse, e.g., forum.posit.co. Note: currently just alias \"gh\". advertise Logical. Whether include footer describes reprex created. unspecified, option reprex.advertise consulted , defined, default TRUE venues \"gh\", \"html\", \"\", \"ds\" FALSE \"r\", \"rtf\", \"slack\". session_info Logical. Whether include sessioninfo::session_info(), available, sessionInfo() end reprex. venue \"gh\", session info wrapped collapsible details tag. Read opt(). style Logical. Whether set knitr chunk option tidy = \"styler\", re-styles code styler package. Read opt(). comment Character. Prefix comment output, defaults \"#>\". Read opt(). tidyverse_quiet Logical. Sets options tidyverse.quiet tidymodels.quiet, suppress (TRUE, default) include (FALSE) startup messages tidyverse tidymodels packages. Read opt(). std_out_err Logical. Whether append section output sent stdout stderr reprex rendering process. can necessary reveal output reprex spawns child processes system() calls. Note properly interleaved output main R process, guarantee lines standard output standard error correct chronological order. See callr::r() . Read opt(). pandoc_args Additional command line options pass pandoc","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_document.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"reprex output format — reprex_document","text":"R Markdown output format pass rmarkdown::render().","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_document.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"reprex output format — reprex_document","text":"","code":"reprex_document() #> $knitr #> $knitr$opts_chunk #> $knitr$opts_chunk$dev #> [1] \"png\" #> #> $knitr$opts_chunk$dpi #> [1] 96 #> #> $knitr$opts_chunk$fig.width #> [1] 7 #> #> $knitr$opts_chunk$fig.height #> [1] 5 #> #> $knitr$opts_chunk$fig.retina #> NULL #> #> $knitr$opts_chunk$collapse #> [1] TRUE #> #> $knitr$opts_chunk$error #> [1] TRUE #> #> $knitr$opts_chunk$comment #> [1] \"#>\" #> #> $knitr$opts_chunk$R.options #> $knitr$opts_chunk$R.options$tidyverse.quiet #> [1] TRUE #> #> $knitr$opts_chunk$R.options$tidymodels.quiet #> [1] TRUE #> #> #> #> $knitr$opts_knit #> $knitr$opts_knit$upload.fun #> function (file, key = xfun::env_option(\"knitr.imgur.key\", \"9f3460e67f308f6\"), #> ...) #> { #> xfun::upload_imgur(file, key, ..., include_xml = TRUE) #> } #> #> #> #> #> $knitr$knit_hooks #> NULL #> #> $knitr$opts_hooks #> NULL #> #> $knitr$opts_template #> NULL #> #> #> $pandoc #> $pandoc$to #> [1] \"gfm-yaml_metadata_block\" #> #> $pandoc$from #> [1] \"markdown+autolink_bare_uris+tex_math_single_backslash-implicit_figures\" #> #> $pandoc$args #> [1] \"--wrap=preserve\" #> #> $pandoc$keep_tex #> [1] FALSE #> #> $pandoc$latex_engine #> [1] \"pdflatex\" #> #> $pandoc$ext #> [1] \".md\" #> #> $pandoc$convert_fun #> NULL #> #> #> $keep_md #> [1] FALSE #> #> $clean_supporting #> [1] FALSE #> #> $df_print #> [1] \"default\" #> #> $pre_knit #> function (input, ...) #> { #> knit_input <- sub(\"[.]R$\", \".spin.Rmd\", input) #> input_lines <- read_lines(knit_input) #> input_lines <- c(rprofile_alert(venue), \"\", input_lines) #> input_lines <- c(reprex_opts(venue), \"\", input_lines) #> if (isTRUE(advertise)) { #> input_lines <- c(input_lines, \"\", ad(venue)) #> } #> if (isTRUE(std_out_err)) { #> input_lines <- c(input_lines, \"\", std_out_err_stub(input, #> venue)) #> } #> if (isTRUE(session_info)) { #> input_lines <- c(input_lines, \"\", si(venue)) #> } #> write_lines(input_lines, knit_input) #> } #> #> #> #> $post_knit #> NULL #> #> $pre_processor #> NULL #> #> $intermediates_generator #> NULL #> #> $post_processor #> NULL #> #> $file_scope #> NULL #> #> $on_exit #> function () #> { #> if (is.function(base)) #> base() #> if (is.function(overlay)) #> overlay() #> } #> #> #> #> attr(,\"class\") #> [1] \"rmarkdown_output_format\""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a reprex in a specific locale — reprex_locale","title":"Render a reprex in a specific locale — reprex_locale","text":"Render reprex(), control localization error messages aspects locale. Note related distinct issues! Typical usage someone Spanish system create reprex easier English-speaking audience follow.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a reprex in a specific locale — reprex_locale","text":"","code":"reprex_locale(..., language = \"en\", locale = NULL)"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a reprex in a specific locale — reprex_locale","text":"... Inputs passed reprex(). language string specifying preferred language messages. enacted via LANGUAGE environment variable, duration reprex() call. Examples: \"en\" English \"fr\" French. See Details . locale named character vector, specifying aspects locale, Sys.setlocale() sense. enacted setting one environment variables, duration reprex() call. See Details .","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a reprex in a specific locale — reprex_locale","text":"Character vector rendered reprex, invisibly.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"language","dir":"Reference","previous_headings":"","what":"language","title":"Render a reprex in a specific locale — reprex_locale","text":"Use language argument express preferred language error messages. output dir(system.file(package = \"translations\")) may provide helpful ideas. language generally follow \"XPG syntax\": two-letter language code, optionally followed modifiers. Examples: \"en\", \"de\", \"en_GB\", \"pt_BR\".","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"locale","dir":"Reference","previous_headings":"","what":"locale","title":"Render a reprex in a specific locale — reprex_locale","text":"Use locale argument want affect something like day---week month converted character. less likely need set language argument. may success setting specific categories, \"LC_TIME\", multi-category shortcuts like \"LC_ALL\" \"LANG\". locale values must follow format dictated operating system requested locale must installed. *nix systems, locale -good way see locales installed. Note format locale language different Windows. Examples: \"en_CA.UTF-8\" (macOS), \"French_France.1252\" (Windows).","code":""},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render a reprex in a specific locale — reprex_locale","text":"","code":"if (FALSE) { # \\dontrun{ # if all you want to do is make sure messages are in English reprex_locale(\"a\" / 2) # change messages to a specific language reprex_locale( { \"a\" / 2 }, language = \"it\" ) reprex_locale( { \"a\" / 2 }, language = \"fr_CA\" ) reprex_locale( { \"a\" / 2 }, language = \"pt_BR\" ) # get day-of-week and month to print in French (not Windows) reprex_locale( { format(as.Date(c(\"2019-01-01\", \"2019-02-01\")), \"%a %b %d\") }, locale = c(LC_TIME = \"fr_FR\") ) # get day-of-week and month to print in French (Windows) # assumes that the relevant language is installed on the system # LC_TIME can also be specified as \"French\" or \"French_France\" here reprex_locale( { format(as.Date(c(\"2019-01-01\", \"2019-02-01\")), \"%a %b %d\") }, locale = c(LC_TIME = \"French_France.1252\") ) } # }"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_options.html","id":null,"dir":"Reference","previous_headings":"","what":"reprex options — reprex_options","title":"reprex options — reprex_options","text":"reprex() behaviour can controlled via option, providing way user set personal defaults. pattern option names reprex., argument reprex(). main ones: reprex.advertise reprex.session_info (previously, reprex.si) reprex.style reprex.html_preview (previously, reprex.show) reprex.comment reprex.tidyverse_quiet reprex.std_out_err options exist, relevant specific situations: reprex.venue: Can used control venue used reprex_selection() addin. reprex.current_venue: Read-option set reprex_render(). packages want generate reprex-compatible output can consult via getOption(\"reprex.current_venue\"), want tailor output venue. reprex.clipboard: FALSE, reprex makes attempt access user's clipboard, ever. exists mostly internal use, .e. set FALSE detect use RStudio Server. user set FALSE explicitly opt-clipboard functionality. Linux user intention installing xclip xsel might also . reprex.highlight.hl_style: relevant venue = \"rtf. Details article reprex venue RTF. reprex.highlight.font: See . reprex.highlight.font_size: See . reprex.highlight.: See . code put .Rprofile set reprex options. rare want non-default behaviour ! sake exposition: function usethis::edit_r_profile() handy creating /opening .Rprofile.","code":"options( reprex.advertise = FALSE, reprex.session_info = TRUE, reprex.style = TRUE, reprex.html_preview = FALSE, reprex.comment = \"#;-)\", reprex.tidyverse_quiet = FALSE, reprex.std_out_err = TRUE, reprex.venue = \"html\", # NOTE: only affects reprex_selection()! reprex.highlight.hl_style = \"acid\", # NOTE: only affects RTF venue reprex.highlight.font = \"Andale Mono Regular\", reprex.highlight.font_size = 35, reprex.highlight.other = \"--line-numbers\" )"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_options.html","id":"explaining-the-opt-helper","dir":"Reference","previous_headings":"","what":"Explaining the opt() helper","title":"reprex options — reprex_options","text":"Arguments appear like reprex(): get value according logic: shorthand : exported function called directly.","code":"reprex(..., arg = opt(DEFAULT), ...) user-specified value or, if not given, getOption(\"reprex.arg\") or, if does not exist, DEFAULT f(..., arg = getOption(\"reprex.arg\", DEFAULT), ...)"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_render.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a document in a new R session — reprex_render","title":"Render a document in a new R session — reprex_render","text":"wrapper around rmarkdown::render() enforces \"reprex\" mentality. simplified version happens: Key features note rmarkdown::render() executed new R session, using callr::r(). goal eliminate leakage objects, attached packages, aspects session state current session rendering session. Also, system user-level .Rprofiles ignored. Code evaluated globalenv() new R session, means method dispatch works way people expect . input file assumed UTF-8, knitr requirement v1.24. YAML frontmatter includes std_err_out: TRUE, standard output error rendering R session captured std_file, injected rendered result. reprex_render() designed work reprex_document() output format, typically call reprex(). reprex_render() may work R Markdown output formats, well-tested.","code":"callr::r( function(input) { rmarkdown::render(input, envir = globalenv(), encoding = \"UTF-8\") }, args = list(input = input), spinner = is_interactive(), stdout = std_file, stderr = std_file )"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_render.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a document in a new R session — reprex_render","text":"","code":"reprex_render(input, html_preview = NULL, encoding = \"UTF-8\")"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_render.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a document in a new R session — reprex_render","text":"input input file rendered. can .R script .Rmd R Markdown document. html_preview Logical. Whether show rendered output viewer (RStudio browser). Always FALSE noninteractive session. Read opt(). encoding encoding input file. Note acceptable value \"UTF-8\", required knitr v1.24. exposed argument purely technical convenience, relating \"Knit\" button RStudio IDE.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_render.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a document in a new R session — reprex_render","text":"output rmarkdown::render() passed , .e. path output file.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_render.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render a document in a new R session — reprex_render","text":"","code":"if (FALSE) { # \\dontrun{ reprex_render(\"input.Rmd\") } # }"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_venue.html","id":null,"dir":"Reference","previous_headings":"","what":"Venue-specific shortcuts — reprex_venue","title":"Venue-specific shortcuts — reprex_venue","text":"thin wrappers around reprex() incorporate target venue suffix function name, easier access via auto-completion.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_venue.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Venue-specific shortcuts — reprex_venue","text":"","code":"reprex_html(...) reprex_r(...) reprex_rtf(...) reprex_slack(...)"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_venue.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Venue-specific shortcuts — reprex_venue","text":"... Passed along reprex().","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/un-reprex.html","id":null,"dir":"Reference","previous_headings":"","what":"Un-render a reprex — un-reprex","title":"Un-render a reprex — un-reprex","text":"Recover clean, runnable code reprex captured wild write user's clipboard. code also returned invisibly optionally written file. Three different functions address various forms wild-caught reprex: reprex_invert() attempts reverse effect reprex(). venue = \"r\", just calls reprex_clean(). reprex_clean() removes commented output. assumes R code top-level, possibly interleaved commented output, e.g., displayed reprex copied GitHub output reprex(..., venue = \"R\"). reprex_rescue() removes lines output strips prompts lines holding R commands. assumes R code lines start prompt printed output top-level, e.g., copied R Console.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/un-reprex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Un-render a reprex — un-reprex","text":"","code":"reprex_invert( input = NULL, wd = NULL, venue = c(\"gh\", \"r\"), comment = opt(\"#>\"), outfile = deprecated() ) reprex_clean( input = NULL, wd = NULL, comment = opt(\"#>\"), outfile = deprecated() ) reprex_rescue( input = NULL, wd = NULL, prompt = getOption(\"prompt\"), continue = getOption(\"continue\"), outfile = deprecated() )"},{"path":"https://reprex.tidyverse.org/dev/reference/un-reprex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Un-render a reprex — un-reprex","text":"input Character. length one lacks terminating newline, interpreted path file containing reprex. Otherwise, assumed hold reprex character vector. provided, clipboard consulted input. clipboard unavailable RStudio, current selection used. wd optional filepath consulted input filepath. (default, work done, quietly, subdirectory session temp directory.) common use wd set wd = \".\", means \"reprex right current working directory\". really must demonstrate something local files. venue Character. Must one following (case insensitive): \"gh\" GitHub-Flavored Markdown, default \"r\" runnable R script, commented output interleaved. Also useful Slack code snippets; select \"R\" \"Type\" drop-menu enjoy nice syntax highlighting. \"rtf\" Rich Text Format (supported un-reprexing) \"html\" HTML fragment suitable inclusion larger HTML document (supported un-reprexing) \"slack\" pasting Slack message. Optimized people opt Slack's WYSIWYG interface. Go Preferences > Advanced > Input options select \"Format messages markup\". (demand second Slack venue optimized use WYSIWYG, please open issue discuss.) \"\" Stack Overflow Markdown. Note: just alias \"gh\", since Stack Overflow started support CommonMark-style fenced code blocks January 2019. \"ds\" Discourse, e.g., forum.posit.co. Note: currently just alias \"gh\". comment regular expression matches commented output lines outfile favor wd providing filepath input. reprex current working directory, use wd = \".\" now, instead outfile = NA. prompt character, prompt start R commands continue character, prompt continuation lines","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/un-reprex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Un-render a reprex — un-reprex","text":"Character vector holding just clean R code, invisibly","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/un-reprex.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Un-render a reprex — un-reprex","text":"","code":"if (FALSE) { # \\dontrun{ # a roundtrip: R code --> rendered reprex, as gfm --> R code original <- file.path(tempdir(), \"original.R\") writeLines(glue::glue(\" #' Some text #+ chunk-label-and-options-cannot-be-recovered, message = TRUE (x <- 1:4) #' More text y <- 2:5 x + y\"), con = original) reprex(input = original, html_preview = FALSE, advertise = FALSE) reprexed <- sub(\"[.]R$\", \"_reprex.md\", original) writeLines(readLines(reprexed)) unreprexed <- reprex_invert(input = reprexed) writeLines(unreprexed) # clean up file.remove( list.files(dirname(original), pattern = \"original\", full.names = TRUE) ) } # } if (FALSE) { # \\dontrun{ # a roundtrip: R code --> rendered reprex, as R code --> original R code code_in <- c( \"# a regular comment, which is retained\", \"(x <- 1:4)\", \"median(x)\" ) reprexed <- reprex(input = code_in, venue = \"r\", advertise = FALSE) writeLines(reprexed) code_out <- reprex_clean(input = reprexed) writeLines(code_out) identical(code_in, code_out) } # } if (FALSE) { # \\dontrun{ # rescue a reprex that was copied from a live R session from_r_console <- c( \"> # a regular comment, which is retained\", \"> (x <- 1:4)\", \"[1] 1 2 3 4\", \"> median(x)\", \"[1] 2.5\" ) rescued <- reprex_rescue(input = from_r_console) writeLines(rescued) } # }"},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-211","dir":"Changelog","previous_headings":"","what":"reprex 2.1.1","title":"reprex 2.1.1","text":"CRAN release: 2024-07-06 reprex(style = FALSE) never nag installing styler (#461). Various URLs updated (#458, @olivroy).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-210","dir":"Changelog","previous_headings":"","what":"reprex 2.1.0","title":"reprex 2.1.0","text":"CRAN release: 2024-01-11 reprex() longer includes full traceback default, useful relatively rare situations, otherwise adds bunch clutter (#448). unexported prex_*() functions protect current session option changes coming reprex’s machinery, disabling color (#427).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-202","dir":"Changelog","previous_headings":"","what":"reprex 2.0.2","title":"reprex 2.0.2","text":"CRAN release: 2022-08-17 ad placed reprex(advertise = TRUE) tweaked venue = \"gh\" (, therefore, aliases \"\" \"ds\") venue = \"slack\" (#395). reprex takes advantage rlang 1.0.0’s improved support backtraces knitted documents sets option rlang_backtrace_on_error_report = \"full\" (#377). reprex_rtf() (shortcut reprex(venue = \"rtf\")) now works Windows, even one (possibly temporary) filepaths contains space, e.g. username contains space (#409, @cderv). RStudio addin longer displays warning condition length selecting ‘current file’ reprex source (#391, @bisaloo). Internal matters: Help files man/ re-generated, give rise valid HTML5. (impetus release, keep package safely CRAN.) reprex’s condition signalling updated use current approaches provided cli, rlang, lifecycle packages.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-201","dir":"Changelog","previous_headings":"","what":"reprex 2.0.1","title":"reprex 2.0.1","text":"CRAN release: 2021-08-05 reprex_document() adjusted compatibility changes introduced Pandoc 2.13 around YAML headers (#375, #383 @cderv). reprex_rtf() (unexported prex_rtf()) work . One filepaths involved highlight call broken, now ’s (#379). unexported prex_*() functions write files temporary directory, opposed current working directory (#380).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-200","dir":"Changelog","previous_headings":"","what":"reprex 2.0.0","title":"reprex 2.0.0","text":"CRAN release: 2021-04-02","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"when-the-clipboard-isnt-available-2-0-0","dir":"Changelog","previous_headings":"","what":"When the clipboard isn’t available","title":"reprex 2.0.0","text":"’ve made reprex pleasant use settings access user’s clipboard R. Specifically, applies use RStudio Server RStudio Cloud. reprex() called without expr input, context user’s clipboard can’t reached R, default now consult current selection reprex source. Previously available via reprex_selection() addin. Note “current selection” default behaviour propagates convenience wrappers around reprex(), reprex_locale() venue-specific functions like reprex_r(), un-reprex() functions, reprex_clean(). context, file containing (un)rendered reprex opened user can manually copy contents.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"filepaths-2-0-0","dir":"Changelog","previous_headings":"","what":"Filepaths","title":"reprex 2.0.0","text":"wd new argument set reprex working directory. result, outfile argument deprecated input argument new significance. ’s use input wd control reprex filepaths: reprex current working directory, Previously: reprex(outfile = NA) Now: reprex(wd = \".\") generally, usage looks like reprex(wd = \"path//desired/wd\"). really care reprex filename (location), write source path//stuff.R call reprex(input = \"path//stuff.R\"). input filepath, filepath determines working directory reprex files named wd never even consulted. Various changes mean users see reprex filepaths. Therefore, ’ve revised self-explanatory human-friendly. reprex needs invent file name, now based random “adjective-animal” slug. Bring angry-hamster!","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"rprofile-2-0-0","dir":"Changelog","previous_headings":"","what":".Rprofile","title":"reprex 2.0.0","text":"reprex() renders reprex separate, fresh R session using callr::r(). callr 3.4.0 (released 2019-12-09), default became callr::r(..., user_profile = \"project\"), means callr executes .Rprofile found current working directory. reprexes happen temp directory .Rprofile. user intentionally reprexes existing project .Rprofile, callr::r() therefore reprex() honor . version reprex: explicitly make sure working directory callr::r() call effective working directory reprex. alert user local .Rprofile found. indicate usage local .Rprofile rendered reprex. changes special interest users renv package, uses .Rprofile implement project-specific R package library. Combined filepath changes (described ), means renv user can call reprex(wd = \".\"), render reprex respect project-specific library.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"other-2-0-0","dir":"Changelog","previous_headings":"","what":"Other","title":"reprex 2.0.0","text":"HTML preview work better ways using reprex_render(), .e. usage doesn’t come via call reprex() (#293).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"dependency-changes-2-0-0","dir":"Changelog","previous_headings":"","what":"Dependency changes","title":"reprex 2.0.0","text":"rstudioapi moves Suggests Imports. Related improving experience reprex access user’s clipboard. mockr new Suggests; ’s used tests. bumped documented minimum version Pandoc, use gfm markdown variant get GitHub-Flavored Markdown. gfm variant introduced Pandoc 2.0 (released 2017-10-29).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-100","dir":"Changelog","previous_headings":"","what":"reprex 1.0.0","title":"reprex 1.0.0","text":"CRAN release: 2021-01-27","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"venues-1-0-0","dir":"Changelog","previous_headings":"","what":"Venues","title":"reprex 1.0.0","text":"reprex_VENUE(...) new way call reprex(..., venue = \"VENUE\"). example, reprex_r() equivalent reprex(venue = \"r\"). makes non-default venues easier access via auto-completion (#256). \"slack\" new venue tweaks default Markdown output pasting Slack messages. removes r language identifier opening code fence, simplifies image links , default, suppresses ad. Note venue = \"slack\" reprex_slack() work best people opt-WYSIWYG message editor: Preferences > Advanced, select “Format messages markup”. venue = \"\" (= Stack Overflow) converged default venue = \"gh\" (GitHub). January 2019, supports CommonMark fenced code blocks. remaining difference Stack Overflow support collapsible details tag use GitHub reduce clutter , e.g., session info (#231). \"rtf\" (Rich Text Format) new experimental venue pasting applications like PowerPoint Keynote. experimental requires working installation highlight command line tool, left somewhat fiddly exercise user (#331). venue = \"rtf\" documented article. reprex.current_venue new read-option set reprex_render(). packages can use generate reprex()-compatible, venue-aware output, renv lockfile.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"implementation-and-internals-1-0-0","dir":"Changelog","previous_headings":"","what":"Implementation and internals","title":"reprex 1.0.0","text":"reprex() internally refactored make better use official machinery extending rmarkdown: reprex_document() new R Markdown output format. reprex_render() newly exported function. reprex_document() designed rendered reprex_render(). reprex_render() designed act reprex_document(). (still) heart reprex() function , addition various interface workflow niceties. Two R Markdown templates ship package, RStudio user can access via File > New File > R Markdown … > Template. One minimal; uses lots reprex features. include knit: reprex::reprex_render YAML, causes RStudio “Knit” button use reprex_render(). prex(), prex_VENUE(), prex_render() new unexported functions , like reprex(), render small bit code, much less reproducibility! code evaluated global workspace current process, current working directory. pragmatic hack useful preparing series related snippets, e.g., Keynote PowerPoint presentation, ’s enough space make one self-contained. UTF-8 encoding: Following lead knitr, reprex makes explicit use UTF-8 internally (#237 @krlmlr, #261). reprex causes R crash, reprex(std_out_err = TRUE) able provide information crash, cases (#312).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"other-changes-and-improvements-1-0-0","dir":"Changelog","previous_headings":"","what":"Other changes and improvements","title":"reprex 1.0.0","text":"tidyverse_quiet argument reprex.tidyverse_quiet option also control startup messages tidymodels meta-package (#326, @juliasilge). reprex_locale() new thin wrapper around reprex() renders temporarily-altered locale (#250). si argument reprex() now session_info. explicit seems important saving characters, given auto-completion. show argument reprex() now html_preview, sake consistency R Markdown output formats. New article techniques making package startup quieter (#187, @marionlouveaux).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"dependency-changes-1-0-0","dir":"Changelog","previous_headings":"","what":"Dependency changes","title":"reprex 1.0.0","text":"R 3.1 R 3.2 longer explicitly supported tested. general practice support current release (4.0, time writing), devel, 4 previous versions R (3.6, 3.5, 3.4, 3.3). sessioninfo new Suggests, replacing devtools. glue new Imports, replacing whisker. knitr moves Suggests Imports (although already hard dependency via rmarkdown), can require v1.23 higher, represents major switch UTF-8. cli new Imports. reprex now relies testthat >= 3.0.0 , specifically, uses third edition features.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-030","dir":"Changelog","previous_headings":"","what":"reprex 0.3.0","title":"reprex 0.3.0","text":"CRAN release: 2019-05-16 crayon.enabled option explicitly set FALSE rendering reprex (#238, #239). Expression input captured via substitute() (opposed rlang::enexpr()), favorable reprexes involving tidy eval (#241). New venue “html” render HTML fragments, useful pasting sites without markdown allow HTML (#236 @cwickham). YAML reprex’s template updated light stricter YAML parser used Pandoc >= 2.2.2. rlang::set_attrs() soft-deprecated longer used internally.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-021","dir":"Changelog","previous_headings":"","what":"reprex 0.2.1","title":"reprex 0.2.1","text":"CRAN release: 2018-09-16 reprex ad formatted superscript venue = \"gh\" venue = \"\", .e. subtle (#201). New experimental venue “rtf” produces syntax highlighted snippets suitable pasting presentation software Keynote PowerPoint. venue discussed article (#26). Arguments opts_chunk opts_knit removed reprex(). effect always achievable via roxygen comments reprex code examples always demonstrated . Overriding knitr options doesn’t seem come often enough real-world reprex() usage justify arguments. Internal file system operations use fs package. make user-facing changes reprex definitely want know .","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-020","dir":"Changelog","previous_headings":"","what":"reprex 0.2.0","title":"reprex 0.2.0","text":"CRAN release: 2018-06-22 reprex website: https://reprex.tidyverse.org. includes contributed article @njtierney (#103). reprex moved tidyverse Organization. installed part tidyverse meta-package suggested seeking help. reprex() gains several arguments many arguments can now controlled via option, case user wants defaults. new reprex_selection() add-reprexes current selection, venue controlled option reprex.venue. can handy bind keyboard shortcut (#84 @hadley). reprex can’t write user’s clipboard (e.g. RStudio server Unix-like systems lacking xclip xsel), offers open output file manual copy.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"option-controlled-arguments-for-custom-defaults-0-2-0","dir":"Changelog","previous_headings":"","what":"Option-controlled arguments for custom defaults","title":"reprex 0.2.0","text":"look like reprex(..., arg = opt(DEFAULT), ...) help file. shorthand arg = getOption(\"reprex.arg\", DEFAULT), .e. option reprex.arg consulted , unset, documented default used. Allows user define default behaviour (#116).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"new-arguments-to-reprex-0-2-0","dir":"Changelog","previous_headings":"","what":"New arguments to reprex():","title":"reprex 0.2.0","text":"advertise: toggles inclusion footer describes reprex created, e.g., “Created 2017-11-16 reprex package (v0.1.1.9000)”. Defaults TRUE (#121, #69). style: requests code restyling via newly-Suggested styler package. styler can cope tidyeval syntactical sugar, e.g. df %>% group_by(!! group_var). Defaults FALSE (#108, #94). tidyverse_quiet: affords control startup message tidyverse meta-package. Defaults TRUE, .e. suppresses message (important special case #70, #100). std_out_err: appends output sent stdout stderr reprex rendering process. can necessary reveal output reprex spawns child processes system() calls. Defaults FALSE (#90, #110). render: determines reprex actually rendered just returns producing templated .R file. internal testing.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"venues-0-2-0","dir":"Changelog","previous_headings":"","what":"Venues","title":"reprex 0.2.0","text":"Line wrapping preserved source via Pandoc option (#145 @jimhester, #175). venue = \"gh\" now targets CommonMark standard GitHub Flavored Markdown (#77). venue = \"\" appropriate whitespace start. venue = \"ds\" new value, corresponding https://www.discourse.org, platform behind community.rstudio.com. currently just alias default \"gh\" GitHub venue, formatting appears compatible. Adding \"ds\" value Discourse can documented guard possibility formatting actually unique.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"other-changes-0-2-0","dir":"Changelog","previous_headings":"","what":"Other changes","title":"reprex 0.2.0","text":"keep.source option set TRUE rendering reprex, reprexes involving srcrefs work (#152). “undo” functions (reprex_invert(), reprex_clean(), reprex_rescue()) handle input outfile like reprex() . outfile argument new (#129, #68). default value knitr’s upload.fun now set according venue. knitr::imgur_upload() venues except \"r\", identity (#125). HTML preview appear RStudio Viewer consistently, especially Windows (#75 @yutannihilation). rigorous use UTF-8 encoding (#76 @yutannihilation). Expression input handling refactored. result, formatR longer Suggested. Trailing comments – inline line – also now retained (#89, #91, #114, @jennybc @jimhester). Custom prompts now escaped used regexes (#98, #99 @jimhester). Embedded newlines now escaped.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-012","dir":"Changelog","previous_headings":"","what":"reprex 0.1.2","title":"reprex 0.1.2","text":"CRAN release: 2018-01-26 non-functioning release created CRAN maintainers commenting lines code relating clipboard.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-011","dir":"Changelog","previous_headings":"","what":"reprex 0.1.1","title":"reprex 0.1.1","text":"CRAN release: 2017-01-12 Pandoc added SystemRequirements.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-010","dir":"Changelog","previous_headings":"","what":"reprex 0.1.0","title":"reprex 0.1.0","text":"CRAN release: 2017-01-10 outfile = NA causes outfiles left working directory. Filenames based input file, one. reprex() strips leading prompts input code. Added functions reprex_clean(), reprex_invert(), reprex_rescue() order go backwards, .e. recover source wild-caught reprex. venue = \"R\" (\"r\") can used get R script back, augmented commented output. comment argument added specify prefix commented output. Added RStudio addin, accessed via “Render reprex”. input argument reprex() friends handles code string, character vector, file path. reprex rendered via callr::r_safe() thus run clean, separate R process, eliminating leakage objects loaded packages /calling session. reprex() gains optional arguments opts_chunk opts_knit, taking named list input, order supplement override default knitr chunk package options, respectively. (#33) made explicit upload.fun argument unnecessary, ’s gone. upload.fun option defaults knitr::imgur_upload, means figures produced reprex uploaded imgur.com associated image syntax put Markdown, e.g. ![](https://.imgur.com/QPU5Cg9.png). (#15 @paternogbc) Order reprex() arguments changed. reprex() gains si argument request devtools::session_info() sessionInfo() appended reprex code (#6 @dgrtwo). si = TRUE venue = \"gh\" (default), session info wrapped collapsible details tag. See example (#55). Reprex code can provided R expression. (#6 @dgrtwo, #35) reprex() uses clipboard functionality clipr thus work Windows suitably prepared Unix-like systems, addition Mac OS. (#16 @mdlincoln)","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-0009000","dir":"Changelog","previous_headings":"","what":"reprex 0.0.0.9000","title":"reprex 0.0.0.9000","text":"tweeted people actually used !","code":""}] +[{"path":[]},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://reprex.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://reprex.tidyverse.org/dev/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to reprex","title":"Contributing to reprex","text":"outlines propose change reprex. detailed info contributing , tidyverse packages, please see development contributing guide.","code":""},{"path":"https://reprex.tidyverse.org/dev/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to reprex","text":"Small typos grammatical errors documentation may edited directly using GitHub web interface, long changes made source file. YES: edit roxygen comment .R file R/. : edit .Rd file man/.","code":""},{"path":"https://reprex.tidyverse.org/dev/CONTRIBUTING.html","id":"prerequisites","dir":"","previous_headings":"","what":"Prerequisites","title":"Contributing to reprex","text":"make substantial pull request, always file issue make sure someone team agrees ’s problem. ’ve found bug, create associated issue illustrate bug minimal reprex.","code":""},{"path":"https://reprex.tidyverse.org/dev/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"","what":"Pull request process","title":"Contributing to reprex","text":"recommend create Git branch pull request (PR). Look Travis AppVeyor build status making changes. README contain badges continuous integration services used package. New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat. Contributions test cases included easier accept. user-facing changes, add bullet top NEWS.md current development version header describing changes made followed GitHub username, links relevant issue(s)/PR(s).","code":""},{"path":"https://reprex.tidyverse.org/dev/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to reprex","text":"Please note project released Contributor Code Conduct. participating project agree abide terms.","code":""},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 reprex authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://reprex.tidyverse.org/dev/SUPPORT.html","id":null,"dir":"","previous_headings":"","what":"Getting help with reprex","title":"Getting help with reprex","text":"Thanks using reprex. filing issue, places explore pieces put together make process smooth possible. Start making minimal reproducible example using reprex package. OK, ’s funny, package ’re talking ! best provide input, reprex() call, expected result, actual result. Make easy reproduce problem. additional reprex pointers, check Get help! section tidyverse site. Armed reprex, next step figure ask. ’s question: start community.rstudio.com, /StackOverflow. people answer questions. ’s bug: ’re right place, file issue. ’re sure: let community help figure ! problem bug feature request, can easily return report . opening new issue, sure search issues pull requests make sure bug hasn’t reported /already fixed development version. default, search pre-populated :issue :open. can edit qualifiers (e.g. :pr, :closed) needed. example, ’d simply remove :open search issues repo, open closed. right place, need file issue, please review “File issues” paragraph tidyverse contributing guidelines. Thanks help!","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/datapasta-reprex.html","id":"scenario-1-from-spreadsheet-to-reprex-with-tribble_paste","dir":"Articles","previous_headings":"","what":"Scenario 1: From spreadsheet to reprex with tribble_paste()","title":"Using datapasta with reprex","text":"’s easy copy paste nicely formatted data spreadsheet datapasta’s tribble_paste() functionality. ’ve found simplest method : Copy data source onto clipboard. Click Paste tribble datapasta section RStudio Addins drop-. sure assign data frame name, can use elsewhere reprex. datapasta::tribble_paste() output tribble_paste() doesn’t level detail dput(), works well enough scenarios, added benefit easy read screen.","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/datapasta-reprex.html","id":"scenario-2-from-r-object-to-tibble-with-dpasta","dir":"Articles","previous_headings":"","what":"Scenario 2: From R object to tibble with dpasta()","title":"Using datapasta with reprex","text":"Now let’s say data frame R want use reprex. can use datapasta’s dpasta() function render object format result tribble_paste(), . datapasta::dpasta()","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/datapasta-reprex.html","id":"fin","dir":"Articles","previous_headings":"","what":"Fin","title":"Using datapasta with reprex","text":"’s datapasta discussed , sure check documentation. Don’t forget, comes reprex, less always , wield power datapasta wisely.","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/learn-reprex.html","id":"help-me-help-you-creating-reproducible-examples-with-reprex","dir":"Articles","previous_headings":"","what":"Help me help you: Creating reproducible examples with reprex","title":"How to use reprex","text":"reprex? ’s reproducible example. Making great reprex art science webinar cover aspects. reprex makes conversation code efficient pleasant . comes whenever ask someone help, report bug software, propose new feature. reprex package (https://reprex.tidyverse.org) makes especially easy prepare R code reprex, order share sites https://community.rstudio.com, https://github.com, https://stackoverflow.com. habit making little, rigorous, self-contained examples also great side effect making think clearly programming problems. Webinar page: https://resources.rstudio.com/webinars/help--help--creating-reproducible-examples-jenny-bryan Slides SpeakerDeck: https://speakerdeck.com/jennybc/reprex-reproducible-examples--r","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/reprex-dos-and-donts.html","id":"main-requirements","dir":"Articles","previous_headings":"","what":"Main requirements","title":"Reprex do's and don'ts","text":"Use smallest, simplest, built-data possible. Think: iris mtcars. Bore . must make objects, minimize size complexity. Many functions packages already use offer way create small data frame “inline”: read.table() friends text argument. Example: tibble::tribble() lets use natural readable layout. Example: Get just bit something head() indexing result sample(). anything random, consider using set.seed() make repeatable. datapasta package can generate code data.frame(), tibble::tribble(), data.table::data.table() based existing R data frame. example, call tribble_format(head(ChickWeight, 3)) leaves clipboard, ready paste reprex: dput() decent last resort, .e. simply make built-simulated data inline data creation readable format. dput() output human-readable. Avoid possible. Look official examples try write style. Consider adapting one. Include commands strict “need run” basis. Ruthlessly strip anything unrelated specific matter hand. Include every single command required, e.g. loading specific packages via library(foo). Consider including -called “session info”, .e. OS versions R add-packages, ’s conceivable matters. Use reprex(..., session_info = TRUE) . Whitespace rationing effect. Use good coding style. Use reprex(..., style = TRUE) request automated styling code. Pack , pack , don’t take liberties people’s computers. asking people run code! Don’t start rm(list = ls()). anti-social clobber people’s workspaces. Don’t start setwd(\"C:\\Users\\jenny\\path\\\\\\\\\"), won’t work anyone else’s computer. Don’t mask built-functions, .e. don’t define new function named c mean. change options, store original values start, thing, restore : create files, delete ’re done: Don’t delete files objects didn’t create first place. Take advantage R’s built-ability create temporary files directories. Read tempfile() tempdir().","code":"read.csv(text = \"a,b\\n1,2\\n3,4\") #> a b #> 1 1 2 #> 2 3 4 tibble::tribble( ~ a, ~ b, 1, 2, 3, 4 ) #> # A tibble: 2 x 2 #> a b #> #> 1 1 2 #> 2 3 4 tibble::tribble( ~weight, ~Time, ~Chick, ~Diet, 42, 0, \"1\", \"1\", 51, 2, \"1\", \"1\", 59, 4, \"1\", \"1\" ) opar <- par(pch = 19) par(opar) write(x, \"foo.txt\") file.remove(\"foo.txt\")"},{"path":"https://reprex.tidyverse.org/dev/articles/reprex-dos-and-donts.html","id":"this-seems-like-a-lot-of-work","dir":"Articles","previous_headings":"","what":"This seems like a lot of work!","title":"Reprex do's and don'ts","text":"Yes, creating great reprex requires work. asking people work . ’s partnership. 80% time solve problem course writing excellent reprex. YMMV. remaining 20% time, create reprex likely elicit desired behavior others.","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/reprex-dos-and-donts.html","id":"further-reading","dir":"Articles","previous_headings":"","what":"Further reading:","title":"Reprex do's and don'ts","text":"make great R reproducible example? thread StackOverflow","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/reprex-dos-and-donts.html","id":"package-philosophy","dir":"Articles","previous_headings":"","what":"Package philosophy","title":"Reprex do's and don'ts","text":"reprex code: Must run , therefore, run person posting. faking . easy others digest, don’t necessarily run . encouraged include selected bits output. :scream: easy others copy + paste + run, choose. Don’t let inclusion output break executability. Accomplished like : Use rmarkdown::render() run code capture output normally see screen. done separate R process, via callr, guarantee self-contained. Use chunk option comment = \"#>\" include output retaining executability.","code":""},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"how-to-install-highlight","dir":"Articles","previous_headings":"","what":"How to install highlight","title":"reprex venue RTF","text":"highlight website offers downloads various forms, various OSes: http://www.andre-simon.de/zip/download.php macOS users use homebrew, works: Windows users use chocolatey, works: Windows, chocolatey method add highlight PATH affect methods installation well. case, ’ll need manually. case, needed add C:\\Program Files\\Highlight PATH. second issue ’ve seen scoop package manager Windows, uses shim-based method making executables installs findable. shim method appears less resilient different ways calling highlight R. reprex_rtf() work Sys.(\"highlight\"), executed R, correctly returns path highlight executable. ’s looks macOS: Windows: highlight call implied default behaviour reprex_rtf():","code":"brew install highlight choco install highlight Sys.which(\"highlight\") #> highlight #> \"/usr/local/bin/highlight\" Sys.which(\"highlight\") #> highlight #> \"C:\\\\PROGRA~1\\\\HIGHLI~1\\\\HIGHLI~2.EXE\" highlight -i foo_reprex.R --out-format rtf --no-trailing-nl --encoding=UTF-8 --style darkbone --font 'Courier Regular' --font-size 50 -o foo_reprex.rtf"},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"basic-usage","dir":"Articles","previous_headings":"","what":"Basic usage","title":"reprex venue RTF","text":"Let’s reprex code stick Keynote slide non-R “features”.","code":"reprex({ (x <- rnorm(3)) mean(x) }, venue = \"rtf\")"},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"highlight-options","dir":"Articles","previous_headings":"","what":"highlight options","title":"reprex venue RTF","text":"don’t like defaults, control highlight command line arguments setting reprex.highlight.* options. options? didn’t want burden reprex() even arguments usually something want set globally entire project talk course. Set options code like : supported options reprex.highlight.hl_style, reprex.highlight.font, reprex.highlight.font_size (shown ), reprex.highlight.(catchall anything else, shown ). set options reprexing user-level .Rprofile. Create open file via usethis::edit_r_profile(). also set options specific Project .Rprofile inside Project. Create open file via usethis::edit_r_profile(\"project\"). Finally, might collect R snippets destined inclusion , e.g. talk slides, .R file. make sense set reprex.highlight.* options start file. hl_style must one existing highlight themes font must one installed fonts. List available themes: themes look like? galleries probably high overlap themes: http://www.andre-simon.de/doku/highlight/en/theme-samples.phphttps://rclickhandbuch.files.wordpress.com/2014/09/knitrthemesoverview.pdf can also override defaults --fly. ’s single call using withr , bonus, use reprex.highlight.send arbitrary command line arguments highlight: ’s set highlight options part R session: Experience shown hard predict aspects RTF honored paste target document. ’re talking things like font size background color. seems vary greatly across applications operating systems ’ll just experiment find workflow practical . Note even possible create custom highlight theme, e.g. match theme Keynote Powerpoint slide deck respect background color, font, etc. specific example documented -notes.","code":"options( reprex.highlight.hl_style = \"darkbone\", reprex.highlight.font = \"Source Code Pro\", reprex.highlight.font_size = 50 ) highlight --list-scripts=themes withr::with_options( new = c( reprex.highlight.hl_style = \"dusk\", reprex.highlight.font = \"Fira Code Regular\", reprex.highlight.font_size = 35, reprex.highlight.other = \"--line-numbers --line-number-length=2 --zeroes\" ), reprex::reprex(input = c(\"(x <- rnorm(3))\", \"mean(x)\"), venue = \"rtf\") ) op <- options( reprex.highlight.hl_style = \"anotherdark\", reprex.highlight.font = \"Andale Mono Regular\", reprex.highlight.font_size = 60, reprex.highlight.other = \"--line-numbers\" ) reprex::reprex(input = c(\"(x <- rnorm(3))\", \"mean(x)\"), venue = \"rtf\") options(op)"},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"run-or-not","dir":"Articles","previous_headings":"","what":"Run … or not","title":"reprex venue RTF","text":"just want highlight code, run , set chunk option eval = FALSE option, .e. put special comment first line reprex source: source, reprex()ed, include usual output. specific venue = \"rtf\", ’s likely come setting.","code":"#+ eval = FALSE (x <- rnorm(3)) mean(x)"},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"reprexprex-and-friends","dir":"Articles","previous_headings":"What if each snippet can’t be self-contained?","what":"reprex:::prex() and friends","title":"reprex venue RTF","text":"preparing bits code presentation, can impractical make snippet completely self-contained. really need run snippets current workspace session. reprex() allow . unexported function prex() addresses use case. ’s like reprex(), much less reproducible! Code evaluated global environment current R session. Current working directory used. advertise = FALSE default. prex() also “venue suffix” variants, reprex:::prex_rtf(...) short reprex:::prex(..., venue = \"rtf\"). code defines x y current workspace writes file stuff.txt current working directory. Now can show difference prex() reprex(). yields x y can found, even though aren’t defined snippet, stuff.txt can read. different executing code via reprex(): yields: x y can’t found, reprex() works clean session, stuff.txt can’t found, reprex() works temp directory, default. ’re going prex() lot, ’ll want something like .R file snippets project-specific user-level .Rprofile:","code":"x <- 1 y <- 4 writeLines(\"blah blah\", file.path(getwd(), \"stuff.txt\")) prex({ ls() x + y readLines(\"stuff.txt\") }) ls() #> [1] \"x\" \"y\" x + y #> [1] 5 readLines(\"stuff.txt\") #> [1] \"blah blah\" reprex({ ls() x + y readLines(\"stuff.txt\") }) ls() #> character(0) x + y #> Error in eval(expr, envir, enclos): object 'x' not found readLines(\"stuff.txt\") #> Warning in file(con, \"r\"): cannot open file 'stuff.txt': No such file or #> directory #> Error in file(con, \"r\"): cannot open the connection prex <- reprex:::prex prex_rtf <- reprex:::prex_rtf"},{"path":"https://reprex.tidyverse.org/dev/articles/rtf.html","id":"selectively-hide-and-reveal-code","dir":"Articles","previous_headings":"","what":"Selectively hide and reveal code","title":"reprex venue RTF","text":"prex() existed, use cumbersome technique produce small snippets, hiding code. leave case still useful situations. can use knitr chunk options selectively hide code, .e. run large snippet, include small bit output. easiest show example. reprex() code, last three lines output appear output. lines run, .e. str_reverse() defined, bizzaro() generic default method.","code":"#+ include = FALSE str_reverse <- function(x) { vapply( strsplit(x, \"\"), FUN = function(z) paste(rev(z), collapse = \"\"), FUN.VALUE = \"\") } #+ include = FALSE bizarro <- function(x) { UseMethod(\"bizarro\") } bizarro.default <- function(x) { stop( \"Don't know how to make bizzaro <\", class(x)[[1]], \">\", call. = FALSE ) } #+ include = TRUE bizarro.character <- function(x) str_reverse(x) bizarro(c(\"abc\", \"def\")) bizarro(1:5)"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"tldr","dir":"Articles","previous_headings":"","what":"TL;DR","title":"Suppress package startup messages","text":"’s quick look various techniques. described detail . Call library() warn.conflicts = FALSE. Surround chatty library() call suppressPackageStartupMessages(). Break reprex “chunks”, .Rmd sense, use special #+ comment silence messages /warnings chunk holds chatty library() call. Note second #+ comment important, don’t silence messages warnings entire reprex. ’re using one tidyverse packages, consider using tidyverse metapackage, literally. reprex::reprex() argument tidyverse_quiet, defaults TRUE silences startup messages. tidyverse_quiet also silences startup messages tidymodels meta-package.","code":"library(dplyr, warn.conflicts = FALSE) suppressPackageStartupMessages(library(dplyr)) #+ message = FALSE, warning = FALSE library(dplyr) #+ slice(iris, 1) library(tidyverse) slice(iris, 1)"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"dplyr-is-chatty-at-startup","dir":"Articles","previous_headings":"","what":"dplyr is chatty at startup","title":"Suppress package startup messages","text":"dplyr common culprit noisy startup, use example. Note messaging baseline.","code":"library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"warn-conflicts-false","dir":"Articles","previous_headings":"","what":"warn.conflicts = FALSE","title":"Suppress package startup messages","text":"suppress warnings conflicts, set warn.conflicts argument library() FALSE.","code":"library(dplyr, warn.conflicts = FALSE) slice(iris, 1) #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"suppresspackagestartupmessages","dir":"Articles","previous_headings":"","what":"suppressPackageStartupMessages()","title":"Suppress package startup messages","text":"Surround library() suppressPackageStartupMessages().","code":"suppressPackageStartupMessages(library(dplyr)) slice(iris, 1) #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"set-message-false-and-warning-false-for-a-chunk","dir":"Articles","previous_headings":"","what":"Set message = FALSE and warning = FALSE for a chunk","title":"Suppress package startup messages","text":"working R Markdown, suppress messages warnings chunk containing library() calls, put “real code” different chunk: can plain R code, suitable reprex()ing, using special comments start #+. Note second #+ significant, begins new chunk capable emitting messages warnings.","code":"```{r, message = FALSE, warning = FALSE} library(dplyr) ``` Some text. ```{r} slice(iris, 1) ``` #+ message = FALSE, warning = FALSE library(dplyr) message(\"You CANNOT hear me!\") #+ message(\"You can hear me!\") slice(iris, 1)"},{"path":"https://reprex.tidyverse.org/dev/articles/suppress-startup-messages.html","id":"reprex-knows-about-tidyverse_quiet","dir":"Articles","previous_headings":"","what":"reprex knows about tidyverse_quiet","title":"Suppress package startup messages","text":"reprex::reprex() function tidyverse_quiet argument defaults TRUE. reprex uses one tidyverse packages, consider attaching tidyverse metapackage, instead individual packages, order enjoy quiet startup. Note default behaviour can overridden setting tidyverse_quiet = FALSE specific reprex() call setting option reprex.tidyverse_quiet = FALSE .Rprofile startup file. tidyverse_quiet argument reprex.tidyverse_quiet option also affect startup messages tidymodels meta-package.","code":"library(tidyverse) # instead of library(dplyr) slice(iris, 1) #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa"},{"path":"https://reprex.tidyverse.org/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Jennifer Bryan. Author, maintainer. Jim Hester. Author. David Robinson. Author. Hadley Wickham. Author. Christophe Dervieux. Author. . Copyright holder, funder.","code":""},{"path":"https://reprex.tidyverse.org/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Bryan J, Hester J, Robinson D, Wickham H, Dervieux C (2024). reprex: Prepare Reproducible Example Code via Clipboard. R package version 2.1.1.9000, https://github.com/tidyverse/reprex, https://reprex.tidyverse.org.","code":"@Manual{, title = {reprex: Prepare Reproducible Example Code via the Clipboard}, author = {Jennifer Bryan and Jim Hester and David Robinson and Hadley Wickham and Christophe Dervieux}, year = {2024}, note = {R package version 2.1.1.9000, https://github.com/tidyverse/reprex}, url = {https://reprex.tidyverse.org}, }"},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"Prepare Reproducible Example Code via the Clipboard","text":"Prepare reprexes posting GitHub issues, StackOverflow, Slack messages snippets, even paste PowerPoint Keynote slides. reprex? ’s reproducible example, coined Romain Francois tweet 2014. Given R code clipboard, selected RStudio, expression (quoted ), file … run via rmarkdown::render(), deliberate choices re: render() arguments, knitr options, Pandoc options. Get resulting runnable code + output Markdown, suitable GitHub Stack Overflow Slack, R code, augmented commented output, Plain HTML (experimental) Rich Text result returned invisibly, written file , possible, placed clipboard. Preview HTML version RStudio viewer default browser.","code":""},{"path":"https://reprex.tidyverse.org/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Prepare Reproducible Example Code via the Clipboard","text":"Install CRAN: get development version GitHub: Linux, probably want install xclip xsel, reprex can access X11 clipboard. ‘nice ’, mandatory. usual sudo apt-get install sudo yum install installation methods work xclip xsel.","code":"install.packages(\"reprex\") # install.packages(\"pak\") pak::pak(\"tidyverse/reprex\")"},{"path":"https://reprex.tidyverse.org/dev/index.html","id":"usage","dir":"","previous_headings":"","what":"Usage","title":"Prepare Reproducible Example Code via the Clipboard","text":"Let’s say copy code onto clipboard (, RStudio Server Cloud, select ): call reprex(), default target venue GitHub: nicely rendered HTML preview display RStudio’s Viewer (’re RStudio) default browser otherwise. relevant bit GitHub-flavored Markdown ready pasted clipboard (RStudio Server Cloud, need copy ): ’s Markdown look like rendered GitHub issue: Anyone else can copy, paste, run immediately. addition GitHub, Markdown also works Stack Overflow Discourse. venues can formally requested via venue = \"\" venue = \"ds\", just aliases venue = \"gh\". Instead reading clipboard, can: reprex(mean(rnorm(10))) get code expression. reprex(input = \"mean(rnorm(10))\\n\") gets code character vector (detected via length terminating newline). Leading prompts stripped input source: reprex(input = \"> median(1:3)\\n\") produces output reprex(input = \"median(1:3)\\n\") reprex(input = \"my_reprex.R\") gets code file Use one RStudio add-ins use selected text current file. wait, ’s ! Get slightly different Markdown, optimized Slack messages, reprex(..., venue = \"slack\"). Get runnable R script, augmented commented output, reprex(..., venue = \"R\"). useful Slack code snippets, email, etc. Get html reprex(..., venue = \"html\"). Useful sites don’t support Markdown. Prepare (un)rendered, syntax-highlighted code snippets paste Keynote PowerPoint, reprex(..., venue = \"rtf\"). feature still experimental; see associated article . default, figures uploaded imgur.com resulting URL dropped inline image tag. really need reprex specific directory, use wd argument. example, reprex(wd = \".\") requests current working directory. Append session info via reprex(..., session_info = TRUE). Get clean, runnable code wild-caught reprexes reprex_invert() = opposite reprex() reprex_clean(), e.g. copy/paste GitHub Stack Overflow reprex_rescue(), ’re dealing copy/paste R Console","code":"(y <- 1:4) mean(y) reprex() ``` r (y <- 1:4) #> [1] 1 2 3 4 mean(y) #> [1] 2.5 ``` (y <- 1:4) #> [1] 1 2 3 4 mean(y) #> [1] 2.5"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex-package.html","id":null,"dir":"Reference","previous_headings":"","what":"reprex: Prepare Reproducible Example Code via the Clipboard — reprex-package","title":"reprex: Prepare Reproducible Example Code via the Clipboard — reprex-package","text":"Convenience wrapper uses 'rmarkdown' package render small snippets code target formats include code output. goal encourage sharing small, reproducible, runnable examples code-oriented websites, https://stackoverflow.com https://github.com, email. user's clipboard default source input code default target rendered output. 'reprex' also extracts clean, runnable R code various common formats, copy/paste R session.","code":""},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/reference/reprex-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"reprex: Prepare Reproducible Example Code via the Clipboard — reprex-package","text":"Maintainer: Jennifer Bryan jenny@posit.co (ORCID) Authors: Jim Hester (ORCID) David Robinson admiral.david@gmail.com Hadley Wickham hadley@posit.co (ORCID) Christophe Dervieux cderv@posit.co (ORCID) contributors: Posit Software, PBC [copyright holder, funder]","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a reprex — reprex","title":"Render a reprex — reprex","text":"Run bit R code using rmarkdown::render() write rendered result user's clipboard. clipboard unavailable, file containing rendered result opened manual copy. goal make easy share small reproducible example (\"reprex\"), e.g., GitHub issue. Reprex source can read clipboard provided directly expression, character vector, string read file read current selection active document RStudio reprex can also used syntax highlighting (without rendering); see .","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a reprex — reprex","text":"","code":"reprex( x = NULL, input = NULL, wd = NULL, venue = c(\"gh\", \"r\", \"rtf\", \"html\", \"slack\", \"so\", \"ds\"), render = TRUE, advertise = NULL, session_info = opt(FALSE), style = opt(FALSE), comment = opt(\"#>\"), tidyverse_quiet = opt(TRUE), std_out_err = opt(FALSE), html_preview = opt(TRUE), outfile = deprecated(), show = deprecated(), si = deprecated() )"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a reprex — reprex","text":"x expression. given, reprex() looks code input. input provided, reprex() looks clipboard. clipboard structurally unavailable, e.g., RStudio Server RStudio Cloud, reprex() consults current selection instead clipboard. input Character. length one lacks terminating newline, interpreted path file containing reprex code. Otherwise, assumed hold reprex code character vector. input specifies filepath, also determines reprex working directory location resulting files. wd optional filepath consulted input filepath. (default, work done, quietly, subdirectory session temp directory.) common use wd set wd = \".\", means \"reprex right current working directory\". really must demonstrate something local files. venue Character. Must one following (case insensitive): \"gh\" GitHub-Flavored Markdown, default \"r\" runnable R script, commented output interleaved. Also useful Slack code snippets; select \"R\" \"Type\" drop-menu enjoy nice syntax highlighting. \"rtf\" Rich Text Format (supported un-reprexing) \"html\" HTML fragment suitable inclusion larger HTML document (supported un-reprexing) \"slack\" pasting Slack message. Optimized people opt Slack's WYSIWYG interface. Go Preferences > Advanced > Input options select \"Format messages markup\". (demand second Slack venue optimized use WYSIWYG, please open issue discuss.) \"\" Stack Overflow Markdown. Note: just alias \"gh\", since Stack Overflow started support CommonMark-style fenced code blocks January 2019. \"ds\" Discourse, e.g., forum.posit.co. Note: currently just alias \"gh\". render Logical. Whether call rmarkdown::render() templated reprex, .e. whether actually run code. Defaults TRUE. Exists primarily sake internal testing. advertise Logical. Whether include footer describes reprex created. unspecified, option reprex.advertise consulted , defined, default TRUE venues \"gh\", \"html\", \"\", \"ds\" FALSE \"r\", \"rtf\", \"slack\". session_info Logical. Whether include sessioninfo::session_info(), available, sessionInfo() end reprex. venue \"gh\", session info wrapped collapsible details tag. Read opt(). style Logical. Whether set knitr chunk option tidy = \"styler\", re-styles code styler package. Read opt(). comment Character. Prefix comment output, defaults \"#>\". Read opt(). tidyverse_quiet Logical. Sets options tidyverse.quiet tidymodels.quiet, suppress (TRUE, default) include (FALSE) startup messages tidyverse tidymodels packages. Read opt(). std_out_err Logical. Whether append section output sent stdout stderr reprex rendering process. can necessary reveal output reprex spawns child processes system() calls. Note properly interleaved output main R process, guarantee lines standard output standard error correct chronological order. See callr::r() . Read opt(). html_preview Logical. Whether show rendered output viewer (RStudio browser). Always FALSE noninteractive session. Read opt(). outfile favor wd providing filepath input. reprex current working directory, use wd = \".\" now, instead outfile = NA. show favor html_preview, greater consistency R Markdown output formats. si favor session_info.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a reprex — reprex","text":"Character vector rendered reprex, invisibly.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Render a reprex — reprex","text":"usual \"code + commented output\" returned invisibly, written file, , whenever possible, put clipboard. HTML preview displays RStudio's Viewer pane, available, default browser, otherwise. Leading \"> \" prompts, stripped input code. Read https://reprex.tidyverse.org/. reprex sets specific knitr options: Chunk options default collapse = TRUE, comment = \"#>\", error = TRUE. Note error = TRUE, common use case bug reporting. reprex also sets knitr's upload.fun. defaults knitr::imgur_upload() figures produced reprex appear properly GitHub, Stack Overflow, Discourse, Slack. Note imgur_upload() requires packages httr xml2. venue = \"r\", upload.fun set identity(), figures remain local. case, may also want provide filepath input set wd, control reprex files written. can supplement override options special comments code (see examples).","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"error-backtraces","dir":"Reference","previous_headings":"","what":"Error backtraces","title":"Render a reprex — reprex","text":"use rlang::last_error() rlang::last_trace() within reprex, must place different \"chunk\" code generates error. easiest way insert line containing special comment #' error-causing code: Read rlang's documentation: Errors RMarkdown.","code":"f <- function() rlang::abort('foo') f() #' rlang::last_error() rlang::last_trace()"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"syntax-highlighting","dir":"Reference","previous_headings":"","what":"Syntax highlighting","title":"Render a reprex — reprex","text":"secondary use case reprex produce syntax highlighted code snippets, without rendering, paste applications like Microsoft Word, PowerPoint, Keynote. Use venue = \"rtf\" . feature experimental requires installation highlight command line tool. \"rtf\" venue documented article","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render a reprex — reprex","text":"","code":"if (FALSE) { # \\dontrun{ # put some code like this on the clipboard # (y <- 1:4) # mean(y) reprex() # provide code as an expression reprex(rbinom(3, size = 10, prob = 0.5)) reprex({y <- 1:4; mean(y)}) reprex({y <- 1:4; mean(y)}, style = TRUE) # note that you can include newlines in those brackets # in fact, that is often a good idea reprex({ x <- 1:4 y <- 2:5 x + y }) ## provide code via character vector reprex(input = c(\"x <- 1:4\", \"y <- 2:5\", \"x + y\")) ## if just one line, terminate with '\\n' reprex(input = \"rnorm(3)\\n\") ## customize the output comment prefix reprex(rbinom(3, size = 10, prob = 0.5), comment = \"#;-)\") # override a default chunk option reprex({ #+ setup, include = FALSE knitr::opts_chunk$set(collapse = FALSE) #+ actual-reprex-code (y <- 1:4) median(y) }) # add prose, use general markdown formatting reprex({ #' # A Big Heading #' #' Look at my cute example. I love the #' [reprex](https://github.com/tidyverse/reprex#readme) package! y <- 1:4 mean(y) }, advertise = FALSE) # read reprex from file and write resulting files to that location tmp <- file.path(tempdir(), \"foofy.R\") writeLines(c(\"x <- 1:4\", \"mean(x)\"), tmp) reprex(input = tmp) list.files(dirname(tmp), pattern = \"foofy\") # clean up file.remove(list.files(dirname(tmp), pattern = \"foofy\", full.names = TRUE)) # write reprex to file AND keep figure local too, i.e. don't post to imgur tmp <- file.path(tempdir(), \"foofy\") dir.create(tmp) reprex({ #+ setup, include = FALSE knitr::opts_knit$set(upload.fun = identity) #+ actual-reprex-code #' Some prose ## regular comment (x <- 1:4) median(x) plot(x) }, wd = tmp) list.files(dirname(tmp), pattern = \"foofy\") # clean up unlink(tmp, recursive = TRUE) ## target venue = R, also good for email or Slack snippets ret <- reprex({ x <- 1:4 y <- 2:5 x + y }, venue = \"R\") ret ## target venue = html ret <- reprex({ x <- 1:4 y <- 2:5 x + y }, venue = \"html\") ret ## include prompt and don't comment the output ## use this when you want to make your code hard to execute :) reprex({ #+ setup, include = FALSE knitr::opts_chunk$set(comment = NA, prompt = TRUE) #+ actual-reprex-code x <- 1:4 y <- 2:5 x + y }) ## leading prompts are stripped from source reprex(input = c(\"> x <- 1:3\", \"> median(x)\")) } # }"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_addin.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a reprex, conveniently — reprex_addin","title":"Render a reprex, conveniently — reprex_addin","text":"reprex_addin() opens RStudio gadget addin allows say reprex source (clipboard? current selection? active file? file?) control arguments. Appears \"Render reprex\" RStudio Addins menu. reprex_selection() addin reprexes current selection, optionally customised options. Appears \"Reprex selection\" RStudio Addins menu. Heavy users might want create keyboard shortcut. Suggested shortcut: Cmd + Shift + R (macOS) Ctrl + Shift + R (Windows).","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_addin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a reprex, conveniently — reprex_addin","text":"","code":"reprex_addin() reprex_selection(venue = getOption(\"reprex.venue\", \"gh\"))"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_addin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a reprex, conveniently — reprex_addin","text":"venue Character. Must one following (case insensitive): \"gh\" GitHub-Flavored Markdown, default \"r\" runnable R script, commented output interleaved. Also useful Slack code snippets; select \"R\" \"Type\" drop-menu enjoy nice syntax highlighting. \"rtf\" Rich Text Format (supported un-reprexing) \"html\" HTML fragment suitable inclusion larger HTML document (supported un-reprexing) \"slack\" pasting Slack message. Optimized people opt Slack's WYSIWYG interface. Go Preferences > Advanced > Input options select \"Format messages markup\". (demand second Slack venue optimized use WYSIWYG, please open issue discuss.) \"\" Stack Overflow Markdown. Note: just alias \"gh\", since Stack Overflow started support CommonMark-style fenced code blocks January 2019. \"ds\" Discourse, e.g., forum.posit.co. Note: currently just alias \"gh\".","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_document.html","id":null,"dir":"Reference","previous_headings":"","what":"reprex output format — reprex_document","title":"reprex output format — reprex_document","text":"R Markdown output format designed specifically making \"reprexes\", typically created via reprex() function, ultimately renders document reprex_render(). heavily modified version rmarkdown::md_document(). arguments different spheres influence: venue potentially affects input preparation reprex_render(). Add content primary input, prior rendering: advertise session_info std_out_err (also consulted reprex_render()) Influence knitr package chunk options: style comment tidyverse_quiet RStudio users can create new R Markdown documents reprex_document() format using built-templates. File > New File > R Markdown ... > Template choose one : reprex (minimal) reprex (lots features) include knit: reprex::reprex_render YAML, causes RStudio \"Knit\" button use reprex_render(). render documents , .","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_document.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"reprex output format — reprex_document","text":"","code":"reprex_document( venue = c(\"gh\", \"r\", \"rtf\", \"html\", \"slack\", \"so\", \"ds\"), advertise = NULL, session_info = opt(FALSE), style = opt(FALSE), comment = opt(\"#>\"), tidyverse_quiet = opt(TRUE), std_out_err = opt(FALSE), pandoc_args = NULL )"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_document.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"reprex output format — reprex_document","text":"venue Character. Must one following (case insensitive): \"gh\" GitHub-Flavored Markdown, default \"r\" runnable R script, commented output interleaved. Also useful Slack code snippets; select \"R\" \"Type\" drop-menu enjoy nice syntax highlighting. \"rtf\" Rich Text Format (supported un-reprexing) \"html\" HTML fragment suitable inclusion larger HTML document (supported un-reprexing) \"slack\" pasting Slack message. Optimized people opt Slack's WYSIWYG interface. Go Preferences > Advanced > Input options select \"Format messages markup\". (demand second Slack venue optimized use WYSIWYG, please open issue discuss.) \"\" Stack Overflow Markdown. Note: just alias \"gh\", since Stack Overflow started support CommonMark-style fenced code blocks January 2019. \"ds\" Discourse, e.g., forum.posit.co. Note: currently just alias \"gh\". advertise Logical. Whether include footer describes reprex created. unspecified, option reprex.advertise consulted , defined, default TRUE venues \"gh\", \"html\", \"\", \"ds\" FALSE \"r\", \"rtf\", \"slack\". session_info Logical. Whether include sessioninfo::session_info(), available, sessionInfo() end reprex. venue \"gh\", session info wrapped collapsible details tag. Read opt(). style Logical. Whether set knitr chunk option tidy = \"styler\", re-styles code styler package. Read opt(). comment Character. Prefix comment output, defaults \"#>\". Read opt(). tidyverse_quiet Logical. Sets options tidyverse.quiet tidymodels.quiet, suppress (TRUE, default) include (FALSE) startup messages tidyverse tidymodels packages. Read opt(). std_out_err Logical. Whether append section output sent stdout stderr reprex rendering process. can necessary reveal output reprex spawns child processes system() calls. Note properly interleaved output main R process, guarantee lines standard output standard error correct chronological order. See callr::r() . Read opt(). pandoc_args Additional command line options pass pandoc","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_document.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"reprex output format — reprex_document","text":"R Markdown output format pass rmarkdown::render().","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_document.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"reprex output format — reprex_document","text":"","code":"reprex_document() #> $knitr #> $knitr$opts_chunk #> $knitr$opts_chunk$dev #> [1] \"png\" #> #> $knitr$opts_chunk$dpi #> [1] 96 #> #> $knitr$opts_chunk$fig.width #> [1] 7 #> #> $knitr$opts_chunk$fig.height #> [1] 5 #> #> $knitr$opts_chunk$fig.retina #> NULL #> #> $knitr$opts_chunk$collapse #> [1] TRUE #> #> $knitr$opts_chunk$error #> [1] TRUE #> #> $knitr$opts_chunk$comment #> [1] \"#>\" #> #> $knitr$opts_chunk$R.options #> $knitr$opts_chunk$R.options$tidyverse.quiet #> [1] TRUE #> #> $knitr$opts_chunk$R.options$tidymodels.quiet #> [1] TRUE #> #> #> #> $knitr$opts_knit #> $knitr$opts_knit$upload.fun #> function (file, key = xfun::env_option(\"knitr.imgur.key\", \"9f3460e67f308f6\"), #> ...) #> { #> xfun::upload_imgur(file, key, ..., include_xml = TRUE) #> } #> #> #> #> #> $knitr$knit_hooks #> NULL #> #> $knitr$opts_hooks #> NULL #> #> $knitr$opts_template #> NULL #> #> #> $pandoc #> $pandoc$to #> [1] \"gfm-yaml_metadata_block\" #> #> $pandoc$from #> [1] \"markdown+autolink_bare_uris+tex_math_single_backslash-implicit_figures\" #> #> $pandoc$args #> [1] \"--wrap=preserve\" #> #> $pandoc$keep_tex #> [1] FALSE #> #> $pandoc$latex_engine #> [1] \"pdflatex\" #> #> $pandoc$ext #> [1] \".md\" #> #> $pandoc$convert_fun #> NULL #> #> #> $keep_md #> [1] FALSE #> #> $clean_supporting #> [1] FALSE #> #> $df_print #> [1] \"default\" #> #> $pre_knit #> function (input, ...) #> { #> knit_input <- sub(\"[.]R$\", \".spin.Rmd\", input) #> input_lines <- read_lines(knit_input) #> input_lines <- c(rprofile_alert(venue), \"\", input_lines) #> input_lines <- c(reprex_opts(venue), \"\", input_lines) #> if (isTRUE(advertise)) { #> input_lines <- c(input_lines, \"\", ad(venue)) #> } #> if (isTRUE(std_out_err)) { #> input_lines <- c(input_lines, \"\", std_out_err_stub(input, #> venue)) #> } #> if (isTRUE(session_info)) { #> input_lines <- c(input_lines, \"\", si(venue)) #> } #> write_lines(input_lines, knit_input) #> } #> #> #> #> $post_knit #> NULL #> #> $pre_processor #> NULL #> #> $intermediates_generator #> NULL #> #> $post_processor #> NULL #> #> $file_scope #> NULL #> #> $on_exit #> function () #> { #> if (is.function(base)) #> base() #> if (is.function(overlay)) #> overlay() #> } #> #> #> #> attr(,\"class\") #> [1] \"rmarkdown_output_format\""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a reprex in a specific locale — reprex_locale","title":"Render a reprex in a specific locale — reprex_locale","text":"Render reprex(), control localization error messages aspects locale. Note related distinct issues! Typical usage someone Spanish system create reprex easier English-speaking audience follow.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a reprex in a specific locale — reprex_locale","text":"","code":"reprex_locale(..., language = \"en\", locale = NULL)"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a reprex in a specific locale — reprex_locale","text":"... Inputs passed reprex(). language string specifying preferred language messages. enacted via LANGUAGE environment variable, duration reprex() call. Examples: \"en\" English \"fr\" French. See Details . locale named character vector, specifying aspects locale, Sys.setlocale() sense. enacted setting one environment variables, duration reprex() call. See Details .","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a reprex in a specific locale — reprex_locale","text":"Character vector rendered reprex, invisibly.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"language","dir":"Reference","previous_headings":"","what":"language","title":"Render a reprex in a specific locale — reprex_locale","text":"Use language argument express preferred language error messages. output dir(system.file(package = \"translations\")) may provide helpful ideas. language generally follow \"XPG syntax\": two-letter language code, optionally followed modifiers. Examples: \"en\", \"de\", \"en_GB\", \"pt_BR\".","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"locale","dir":"Reference","previous_headings":"","what":"locale","title":"Render a reprex in a specific locale — reprex_locale","text":"Use locale argument want affect something like day---week month converted character. less likely need set language argument. may success setting specific categories, \"LC_TIME\", multi-category shortcuts like \"LC_ALL\" \"LANG\". locale values must follow format dictated operating system requested locale must installed. *nix systems, locale -good way see locales installed. Note format locale language different Windows. Examples: \"en_CA.UTF-8\" (macOS), \"French_France.1252\" (Windows).","code":""},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_locale.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render a reprex in a specific locale — reprex_locale","text":"","code":"if (FALSE) { # \\dontrun{ # if all you want to do is make sure messages are in English reprex_locale(\"a\" / 2) # change messages to a specific language reprex_locale( { \"a\" / 2 }, language = \"it\" ) reprex_locale( { \"a\" / 2 }, language = \"fr_CA\" ) reprex_locale( { \"a\" / 2 }, language = \"pt_BR\" ) # get day-of-week and month to print in French (not Windows) reprex_locale( { format(as.Date(c(\"2019-01-01\", \"2019-02-01\")), \"%a %b %d\") }, locale = c(LC_TIME = \"fr_FR\") ) # get day-of-week and month to print in French (Windows) # assumes that the relevant language is installed on the system # LC_TIME can also be specified as \"French\" or \"French_France\" here reprex_locale( { format(as.Date(c(\"2019-01-01\", \"2019-02-01\")), \"%a %b %d\") }, locale = c(LC_TIME = \"French_France.1252\") ) } # }"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_options.html","id":null,"dir":"Reference","previous_headings":"","what":"reprex options — reprex_options","title":"reprex options — reprex_options","text":"reprex() behaviour can controlled via option, providing way user set personal defaults. pattern option names reprex., argument reprex(). main ones: reprex.advertise reprex.session_info (previously, reprex.si) reprex.style reprex.html_preview (previously, reprex.show) reprex.comment reprex.tidyverse_quiet reprex.std_out_err options exist, relevant specific situations: reprex.venue: Can used control venue used reprex_selection() addin. reprex.current_venue: Read-option set reprex_render(). packages want generate reprex-compatible output can consult via getOption(\"reprex.current_venue\"), want tailor output venue. reprex.clipboard: FALSE, reprex makes attempt access user's clipboard, ever. exists mostly internal use, .e. set FALSE detect use RStudio Server. user set FALSE explicitly opt-clipboard functionality. Linux user intention installing xclip xsel might also . reprex.highlight.hl_style: relevant venue = \"rtf. Details article reprex venue RTF. reprex.highlight.font: See . reprex.highlight.font_size: See . reprex.highlight.: See . code put .Rprofile set reprex options. rare want non-default behaviour ! sake exposition: function usethis::edit_r_profile() handy creating /opening .Rprofile.","code":"options( reprex.advertise = FALSE, reprex.session_info = TRUE, reprex.style = TRUE, reprex.html_preview = FALSE, reprex.comment = \"#;-)\", reprex.tidyverse_quiet = FALSE, reprex.std_out_err = TRUE, reprex.venue = \"html\", # NOTE: only affects reprex_selection()! reprex.highlight.hl_style = \"acid\", # NOTE: only affects RTF venue reprex.highlight.font = \"Andale Mono Regular\", reprex.highlight.font_size = 35, reprex.highlight.other = \"--line-numbers\" )"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_options.html","id":"explaining-the-opt-helper","dir":"Reference","previous_headings":"","what":"Explaining the opt() helper","title":"reprex options — reprex_options","text":"Arguments appear like reprex(): get value according logic: shorthand : exported function called directly.","code":"reprex(..., arg = opt(DEFAULT), ...) user-specified value or, if not given, getOption(\"reprex.arg\") or, if does not exist, DEFAULT f(..., arg = getOption(\"reprex.arg\", DEFAULT), ...)"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_render.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a document in a new R session — reprex_render","title":"Render a document in a new R session — reprex_render","text":"wrapper around rmarkdown::render() enforces \"reprex\" mentality. simplified version happens: Key features note rmarkdown::render() executed new R session, using callr::r(). goal eliminate leakage objects, attached packages, aspects session state current session rendering session. Also, system user-level .Rprofiles ignored. Code evaluated globalenv() new R session, means method dispatch works way people expect . input file assumed UTF-8, knitr requirement v1.24. YAML frontmatter includes std_err_out: TRUE, standard output error rendering R session captured std_file, injected rendered result. reprex_render() designed work reprex_document() output format, typically call reprex(). reprex_render() may work R Markdown output formats, well-tested.","code":"callr::r( function(input) { rmarkdown::render(input, envir = globalenv(), encoding = \"UTF-8\") }, args = list(input = input), spinner = is_interactive(), stdout = std_file, stderr = std_file )"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_render.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a document in a new R session — reprex_render","text":"","code":"reprex_render(input, html_preview = NULL, encoding = \"UTF-8\")"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_render.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a document in a new R session — reprex_render","text":"input input file rendered. can .R script .Rmd R Markdown document. html_preview Logical. Whether show rendered output viewer (RStudio browser). Always FALSE noninteractive session. Read opt(). encoding encoding input file. Note acceptable value \"UTF-8\", required knitr v1.24. exposed argument purely technical convenience, relating \"Knit\" button RStudio IDE.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_render.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a document in a new R session — reprex_render","text":"output rmarkdown::render() passed , .e. path output file.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_render.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render a document in a new R session — reprex_render","text":"","code":"if (FALSE) { # \\dontrun{ reprex_render(\"input.Rmd\") } # }"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_venue.html","id":null,"dir":"Reference","previous_headings":"","what":"Venue-specific shortcuts — reprex_venue","title":"Venue-specific shortcuts — reprex_venue","text":"thin wrappers around reprex() incorporate target venue suffix function name, easier access via auto-completion.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_venue.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Venue-specific shortcuts — reprex_venue","text":"","code":"reprex_html(...) reprex_r(...) reprex_rtf(...) reprex_slack(...)"},{"path":"https://reprex.tidyverse.org/dev/reference/reprex_venue.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Venue-specific shortcuts — reprex_venue","text":"... Passed along reprex().","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/un-reprex.html","id":null,"dir":"Reference","previous_headings":"","what":"Un-render a reprex — un-reprex","title":"Un-render a reprex — un-reprex","text":"Recover clean, runnable code reprex captured wild write user's clipboard. code also returned invisibly optionally written file. Three different functions address various forms wild-caught reprex: reprex_invert() attempts reverse effect reprex(). venue = \"r\", just calls reprex_clean(). reprex_clean() removes commented output. assumes R code top-level, possibly interleaved commented output, e.g., displayed reprex copied GitHub output reprex(..., venue = \"R\"). reprex_rescue() removes lines output strips prompts lines holding R commands. assumes R code lines start prompt printed output top-level, e.g., copied R Console.","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/un-reprex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Un-render a reprex — un-reprex","text":"","code":"reprex_invert( input = NULL, wd = NULL, venue = c(\"gh\", \"r\"), comment = opt(\"#>\"), outfile = deprecated() ) reprex_clean( input = NULL, wd = NULL, comment = opt(\"#>\"), outfile = deprecated() ) reprex_rescue( input = NULL, wd = NULL, prompt = getOption(\"prompt\"), continue = getOption(\"continue\"), outfile = deprecated() )"},{"path":"https://reprex.tidyverse.org/dev/reference/un-reprex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Un-render a reprex — un-reprex","text":"input Character. length one lacks terminating newline, interpreted path file containing reprex. Otherwise, assumed hold reprex character vector. provided, clipboard consulted input. clipboard unavailable RStudio, current selection used. wd optional filepath consulted input filepath. (default, work done, quietly, subdirectory session temp directory.) common use wd set wd = \".\", means \"reprex right current working directory\". really must demonstrate something local files. venue Character. Must one following (case insensitive): \"gh\" GitHub-Flavored Markdown, default \"r\" runnable R script, commented output interleaved. Also useful Slack code snippets; select \"R\" \"Type\" drop-menu enjoy nice syntax highlighting. \"rtf\" Rich Text Format (supported un-reprexing) \"html\" HTML fragment suitable inclusion larger HTML document (supported un-reprexing) \"slack\" pasting Slack message. Optimized people opt Slack's WYSIWYG interface. Go Preferences > Advanced > Input options select \"Format messages markup\". (demand second Slack venue optimized use WYSIWYG, please open issue discuss.) \"\" Stack Overflow Markdown. Note: just alias \"gh\", since Stack Overflow started support CommonMark-style fenced code blocks January 2019. \"ds\" Discourse, e.g., forum.posit.co. Note: currently just alias \"gh\". comment regular expression matches commented output lines outfile favor wd providing filepath input. reprex current working directory, use wd = \".\" now, instead outfile = NA. prompt character, prompt start R commands continue character, prompt continuation lines","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/un-reprex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Un-render a reprex — un-reprex","text":"Character vector holding just clean R code, invisibly","code":""},{"path":"https://reprex.tidyverse.org/dev/reference/un-reprex.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Un-render a reprex — un-reprex","text":"","code":"if (FALSE) { # \\dontrun{ # a roundtrip: R code --> rendered reprex, as gfm --> R code original <- file.path(tempdir(), \"original.R\") writeLines(glue::glue(\" #' Some text #+ chunk-label-and-options-cannot-be-recovered, message = TRUE (x <- 1:4) #' More text y <- 2:5 x + y\"), con = original) reprex(input = original, html_preview = FALSE, advertise = FALSE) reprexed <- sub(\"[.]R$\", \"_reprex.md\", original) writeLines(readLines(reprexed)) unreprexed <- reprex_invert(input = reprexed) writeLines(unreprexed) # clean up file.remove( list.files(dirname(original), pattern = \"original\", full.names = TRUE) ) } # } if (FALSE) { # \\dontrun{ # a roundtrip: R code --> rendered reprex, as R code --> original R code code_in <- c( \"# a regular comment, which is retained\", \"(x <- 1:4)\", \"median(x)\" ) reprexed <- reprex(input = code_in, venue = \"r\", advertise = FALSE) writeLines(reprexed) code_out <- reprex_clean(input = reprexed) writeLines(code_out) identical(code_in, code_out) } # } if (FALSE) { # \\dontrun{ # rescue a reprex that was copied from a live R session from_r_console <- c( \"> # a regular comment, which is retained\", \"> (x <- 1:4)\", \"[1] 1 2 3 4\", \"> median(x)\", \"[1] 2.5\" ) rescued <- reprex_rescue(input = from_r_console) writeLines(rescued) } # }"},{"path":[]},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-211","dir":"Changelog","previous_headings":"","what":"reprex 2.1.1","title":"reprex 2.1.1","text":"CRAN release: 2024-07-06 reprex(style = FALSE) never nag installing styler (#461). Various URLs updated (#458, @olivroy).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-210","dir":"Changelog","previous_headings":"","what":"reprex 2.1.0","title":"reprex 2.1.0","text":"CRAN release: 2024-01-11 reprex() longer includes full traceback default, useful relatively rare situations, otherwise adds bunch clutter (#448). unexported prex_*() functions protect current session option changes coming reprex’s machinery, disabling color (#427).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-202","dir":"Changelog","previous_headings":"","what":"reprex 2.0.2","title":"reprex 2.0.2","text":"CRAN release: 2022-08-17 ad placed reprex(advertise = TRUE) tweaked venue = \"gh\" (, therefore, aliases \"\" \"ds\") venue = \"slack\" (#395). reprex takes advantage rlang 1.0.0’s improved support backtraces knitted documents sets option rlang_backtrace_on_error_report = \"full\" (#377). reprex_rtf() (shortcut reprex(venue = \"rtf\")) now works Windows, even one (possibly temporary) filepaths contains space, e.g. username contains space (#409, @cderv). RStudio addin longer displays warning condition length selecting ‘current file’ reprex source (#391, @bisaloo). Internal matters: Help files man/ re-generated, give rise valid HTML5. (impetus release, keep package safely CRAN.) reprex’s condition signalling updated use current approaches provided cli, rlang, lifecycle packages.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-201","dir":"Changelog","previous_headings":"","what":"reprex 2.0.1","title":"reprex 2.0.1","text":"CRAN release: 2021-08-05 reprex_document() adjusted compatibility changes introduced Pandoc 2.13 around YAML headers (#375, #383 @cderv). reprex_rtf() (unexported prex_rtf()) work . One filepaths involved highlight call broken, now ’s (#379). unexported prex_*() functions write files temporary directory, opposed current working directory (#380).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-200","dir":"Changelog","previous_headings":"","what":"reprex 2.0.0","title":"reprex 2.0.0","text":"CRAN release: 2021-04-02","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"when-the-clipboard-isnt-available-2-0-0","dir":"Changelog","previous_headings":"","what":"When the clipboard isn’t available","title":"reprex 2.0.0","text":"’ve made reprex pleasant use settings access user’s clipboard R. Specifically, applies use RStudio Server RStudio Cloud. reprex() called without expr input, context user’s clipboard can’t reached R, default now consult current selection reprex source. Previously available via reprex_selection() addin. Note “current selection” default behaviour propagates convenience wrappers around reprex(), reprex_locale() venue-specific functions like reprex_r(), un-reprex() functions, reprex_clean(). context, file containing (un)rendered reprex opened user can manually copy contents.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"filepaths-2-0-0","dir":"Changelog","previous_headings":"","what":"Filepaths","title":"reprex 2.0.0","text":"wd new argument set reprex working directory. result, outfile argument deprecated input argument new significance. ’s use input wd control reprex filepaths: reprex current working directory, Previously: reprex(outfile = NA) Now: reprex(wd = \".\") generally, usage looks like reprex(wd = \"path//desired/wd\"). really care reprex filename (location), write source path//stuff.R call reprex(input = \"path//stuff.R\"). input filepath, filepath determines working directory reprex files named wd never even consulted. Various changes mean users see reprex filepaths. Therefore, ’ve revised self-explanatory human-friendly. reprex needs invent file name, now based random “adjective-animal” slug. Bring angry-hamster!","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"rprofile-2-0-0","dir":"Changelog","previous_headings":"","what":".Rprofile","title":"reprex 2.0.0","text":"reprex() renders reprex separate, fresh R session using callr::r(). callr 3.4.0 (released 2019-12-09), default became callr::r(..., user_profile = \"project\"), means callr executes .Rprofile found current working directory. reprexes happen temp directory .Rprofile. user intentionally reprexes existing project .Rprofile, callr::r() therefore reprex() honor . version reprex: explicitly make sure working directory callr::r() call effective working directory reprex. alert user local .Rprofile found. indicate usage local .Rprofile rendered reprex. changes special interest users renv package, uses .Rprofile implement project-specific R package library. Combined filepath changes (described ), means renv user can call reprex(wd = \".\"), render reprex respect project-specific library.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"other-2-0-0","dir":"Changelog","previous_headings":"","what":"Other","title":"reprex 2.0.0","text":"HTML preview work better ways using reprex_render(), .e. usage doesn’t come via call reprex() (#293).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"dependency-changes-2-0-0","dir":"Changelog","previous_headings":"","what":"Dependency changes","title":"reprex 2.0.0","text":"rstudioapi moves Suggests Imports. Related improving experience reprex access user’s clipboard. mockr new Suggests; ’s used tests. bumped documented minimum version Pandoc, use gfm markdown variant get GitHub-Flavored Markdown. gfm variant introduced Pandoc 2.0 (released 2017-10-29).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-100","dir":"Changelog","previous_headings":"","what":"reprex 1.0.0","title":"reprex 1.0.0","text":"CRAN release: 2021-01-27","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"venues-1-0-0","dir":"Changelog","previous_headings":"","what":"Venues","title":"reprex 1.0.0","text":"reprex_VENUE(...) new way call reprex(..., venue = \"VENUE\"). example, reprex_r() equivalent reprex(venue = \"r\"). makes non-default venues easier access via auto-completion (#256). \"slack\" new venue tweaks default Markdown output pasting Slack messages. removes r language identifier opening code fence, simplifies image links , default, suppresses ad. Note venue = \"slack\" reprex_slack() work best people opt-WYSIWYG message editor: Preferences > Advanced, select “Format messages markup”. venue = \"\" (= Stack Overflow) converged default venue = \"gh\" (GitHub). January 2019, supports CommonMark fenced code blocks. remaining difference Stack Overflow support collapsible details tag use GitHub reduce clutter , e.g., session info (#231). \"rtf\" (Rich Text Format) new experimental venue pasting applications like PowerPoint Keynote. experimental requires working installation highlight command line tool, left somewhat fiddly exercise user (#331). venue = \"rtf\" documented article. reprex.current_venue new read-option set reprex_render(). packages can use generate reprex()-compatible, venue-aware output, renv lockfile.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"implementation-and-internals-1-0-0","dir":"Changelog","previous_headings":"","what":"Implementation and internals","title":"reprex 1.0.0","text":"reprex() internally refactored make better use official machinery extending rmarkdown: reprex_document() new R Markdown output format. reprex_render() newly exported function. reprex_document() designed rendered reprex_render(). reprex_render() designed act reprex_document(). (still) heart reprex() function , addition various interface workflow niceties. Two R Markdown templates ship package, RStudio user can access via File > New File > R Markdown … > Template. One minimal; uses lots reprex features. include knit: reprex::reprex_render YAML, causes RStudio “Knit” button use reprex_render(). prex(), prex_VENUE(), prex_render() new unexported functions , like reprex(), render small bit code, much less reproducibility! code evaluated global workspace current process, current working directory. pragmatic hack useful preparing series related snippets, e.g., Keynote PowerPoint presentation, ’s enough space make one self-contained. UTF-8 encoding: Following lead knitr, reprex makes explicit use UTF-8 internally (#237 @krlmlr, #261). reprex causes R crash, reprex(std_out_err = TRUE) able provide information crash, cases (#312).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"other-changes-and-improvements-1-0-0","dir":"Changelog","previous_headings":"","what":"Other changes and improvements","title":"reprex 1.0.0","text":"tidyverse_quiet argument reprex.tidyverse_quiet option also control startup messages tidymodels meta-package (#326, @juliasilge). reprex_locale() new thin wrapper around reprex() renders temporarily-altered locale (#250). si argument reprex() now session_info. explicit seems important saving characters, given auto-completion. show argument reprex() now html_preview, sake consistency R Markdown output formats. New article techniques making package startup quieter (#187, @marionlouveaux).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"dependency-changes-1-0-0","dir":"Changelog","previous_headings":"","what":"Dependency changes","title":"reprex 1.0.0","text":"R 3.1 R 3.2 longer explicitly supported tested. general practice support current release (4.0, time writing), devel, 4 previous versions R (3.6, 3.5, 3.4, 3.3). sessioninfo new Suggests, replacing devtools. glue new Imports, replacing whisker. knitr moves Suggests Imports (although already hard dependency via rmarkdown), can require v1.23 higher, represents major switch UTF-8. cli new Imports. reprex now relies testthat >= 3.0.0 , specifically, uses third edition features.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-030","dir":"Changelog","previous_headings":"","what":"reprex 0.3.0","title":"reprex 0.3.0","text":"CRAN release: 2019-05-16 crayon.enabled option explicitly set FALSE rendering reprex (#238, #239). Expression input captured via substitute() (opposed rlang::enexpr()), favorable reprexes involving tidy eval (#241). New venue “html” render HTML fragments, useful pasting sites without markdown allow HTML (#236 @cwickham). YAML reprex’s template updated light stricter YAML parser used Pandoc >= 2.2.2. rlang::set_attrs() soft-deprecated longer used internally.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-021","dir":"Changelog","previous_headings":"","what":"reprex 0.2.1","title":"reprex 0.2.1","text":"CRAN release: 2018-09-16 reprex ad formatted superscript venue = \"gh\" venue = \"\", .e. subtle (#201). New experimental venue “rtf” produces syntax highlighted snippets suitable pasting presentation software Keynote PowerPoint. venue discussed article (#26). Arguments opts_chunk opts_knit removed reprex(). effect always achievable via roxygen comments reprex code examples always demonstrated . Overriding knitr options doesn’t seem come often enough real-world reprex() usage justify arguments. Internal file system operations use fs package. make user-facing changes reprex definitely want know .","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-020","dir":"Changelog","previous_headings":"","what":"reprex 0.2.0","title":"reprex 0.2.0","text":"CRAN release: 2018-06-22 reprex website: https://reprex.tidyverse.org. includes contributed article @njtierney (#103). reprex moved tidyverse Organization. installed part tidyverse meta-package suggested seeking help. reprex() gains several arguments many arguments can now controlled via option, case user wants defaults. new reprex_selection() add-reprexes current selection, venue controlled option reprex.venue. can handy bind keyboard shortcut (#84 @hadley). reprex can’t write user’s clipboard (e.g. RStudio server Unix-like systems lacking xclip xsel), offers open output file manual copy.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"option-controlled-arguments-for-custom-defaults-0-2-0","dir":"Changelog","previous_headings":"","what":"Option-controlled arguments for custom defaults","title":"reprex 0.2.0","text":"look like reprex(..., arg = opt(DEFAULT), ...) help file. shorthand arg = getOption(\"reprex.arg\", DEFAULT), .e. option reprex.arg consulted , unset, documented default used. Allows user define default behaviour (#116).","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"new-arguments-to-reprex-0-2-0","dir":"Changelog","previous_headings":"","what":"New arguments to reprex():","title":"reprex 0.2.0","text":"advertise: toggles inclusion footer describes reprex created, e.g., “Created 2017-11-16 reprex package (v0.1.1.9000)”. Defaults TRUE (#121, #69). style: requests code restyling via newly-Suggested styler package. styler can cope tidyeval syntactical sugar, e.g. df %>% group_by(!! group_var). Defaults FALSE (#108, #94). tidyverse_quiet: affords control startup message tidyverse meta-package. Defaults TRUE, .e. suppresses message (important special case #70, #100). std_out_err: appends output sent stdout stderr reprex rendering process. can necessary reveal output reprex spawns child processes system() calls. Defaults FALSE (#90, #110). render: determines reprex actually rendered just returns producing templated .R file. internal testing.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"venues-0-2-0","dir":"Changelog","previous_headings":"","what":"Venues","title":"reprex 0.2.0","text":"Line wrapping preserved source via Pandoc option (#145 @jimhester, #175). venue = \"gh\" now targets CommonMark standard GitHub Flavored Markdown (#77). venue = \"\" appropriate whitespace start. venue = \"ds\" new value, corresponding https://www.discourse.org, platform behind community.rstudio.com. currently just alias default \"gh\" GitHub venue, formatting appears compatible. Adding \"ds\" value Discourse can documented guard possibility formatting actually unique.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"other-changes-0-2-0","dir":"Changelog","previous_headings":"","what":"Other changes","title":"reprex 0.2.0","text":"keep.source option set TRUE rendering reprex, reprexes involving srcrefs work (#152). “undo” functions (reprex_invert(), reprex_clean(), reprex_rescue()) handle input outfile like reprex() . outfile argument new (#129, #68). default value knitr’s upload.fun now set according venue. knitr::imgur_upload() venues except \"r\", identity (#125). HTML preview appear RStudio Viewer consistently, especially Windows (#75 @yutannihilation). rigorous use UTF-8 encoding (#76 @yutannihilation). Expression input handling refactored. result, formatR longer Suggested. Trailing comments – inline line – also now retained (#89, #91, #114, @jennybc @jimhester). Custom prompts now escaped used regexes (#98, #99 @jimhester). Embedded newlines now escaped.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-012","dir":"Changelog","previous_headings":"","what":"reprex 0.1.2","title":"reprex 0.1.2","text":"CRAN release: 2018-01-26 non-functioning release created CRAN maintainers commenting lines code relating clipboard.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-011","dir":"Changelog","previous_headings":"","what":"reprex 0.1.1","title":"reprex 0.1.1","text":"CRAN release: 2017-01-12 Pandoc added SystemRequirements.","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-010","dir":"Changelog","previous_headings":"","what":"reprex 0.1.0","title":"reprex 0.1.0","text":"CRAN release: 2017-01-10 outfile = NA causes outfiles left working directory. Filenames based input file, one. reprex() strips leading prompts input code. Added functions reprex_clean(), reprex_invert(), reprex_rescue() order go backwards, .e. recover source wild-caught reprex. venue = \"R\" (\"r\") can used get R script back, augmented commented output. comment argument added specify prefix commented output. Added RStudio addin, accessed via “Render reprex”. input argument reprex() friends handles code string, character vector, file path. reprex rendered via callr::r_safe() thus run clean, separate R process, eliminating leakage objects loaded packages /calling session. reprex() gains optional arguments opts_chunk opts_knit, taking named list input, order supplement override default knitr chunk package options, respectively. (#33) made explicit upload.fun argument unnecessary, ’s gone. upload.fun option defaults knitr::imgur_upload, means figures produced reprex uploaded imgur.com associated image syntax put Markdown, e.g. ![](https://.imgur.com/QPU5Cg9.png). (#15 @paternogbc) Order reprex() arguments changed. reprex() gains si argument request devtools::session_info() sessionInfo() appended reprex code (#6 @dgrtwo). si = TRUE venue = \"gh\" (default), session info wrapped collapsible details tag. See example (#55). Reprex code can provided R expression. (#6 @dgrtwo, #35) reprex() uses clipboard functionality clipr thus work Windows suitably prepared Unix-like systems, addition Mac OS. (#16 @mdlincoln)","code":""},{"path":"https://reprex.tidyverse.org/dev/news/index.html","id":"reprex-0009000","dir":"Changelog","previous_headings":"","what":"reprex 0.0.0.9000","title":"reprex 0.0.0.9000","text":"tweeted people actually used !","code":""}]