This is an R Markdown output format designed specifically for making
"reprexes", typically created via the reprex()
function, which ultimately
renders the document with reprex_render()
. It is a heavily modified version
of rmarkdown::md_document()
. The arguments have different spheres of
influence:
venue
potentially affects input preparation and reprex_render()
.
Add content to the primary input, prior to rendering:
advertise
session_info
std_out_err
(also consulted by reprex_render()
)
Influence knitr package or chunk options:
style
comment
tidyverse_quiet
RStudio users can create new R Markdown documents with the
reprex_document()
format using built-in templates. Do
File > New File > R Markdown ... > From Template and choose one of:
reprex (minimal)
reprex (lots of features)
Both include knit: reprex::reprex_render
in the YAML, which causes the
RStudio "Knit" button to use reprex_render()
. If you render these documents
yourself, you should do same.
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 )
venue | Character. Must be one of the following (case insensitive):
|
---|---|
advertise | Logical. Whether to include a footer that describes when and
how the reprex was created. If unspecified, the option |
session_info | Logical. Whether to include
|
style | Logical. Whether to set the knitr chunk option |
comment | Character. Prefix with which to comment out output, defaults
to |
tidyverse_quiet | Logical. Sets the options |
std_out_err | Logical. Whether to append a section for output sent to
stdout and stderr by the reprex rendering process. This can be necessary to
reveal output if the reprex spawns child processes or |
pandoc_args | Additional command line options to pass to pandoc |
An R Markdown output format to pass to rmarkdown::render()
.
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 = '9f3460e67f308f6') { #> if (!is.character(key)) stop('The Imgur API Key must be a character string!') #> resp = httr::POST( #> "https://api.imgur.com/3/image.xml", #> config = httr::add_headers(Authorization = paste("Client-ID", key)), #> body = list(image = httr::upload_file(file)) #> ) #> httr::stop_for_status(resp, "upload to imgur") #> res = httr::content(resp, as = "raw") #> res = if (length(res)) xml2::as_list(xml2::read_xml(res)) #> # Breaking change in xml2 1.2.0 #> if (packageVersion('xml2') >= '1.2.0') res <- res[[1L]] #> if (is.null(res$link[[1]])) stop('failed to upload ', file) #> structure(res$link[[1]], XML = res) #> } #> <bytecode: 0x55617393c098> #> <environment: namespace:knitr> #> #> #> $knitr$knit_hooks #> NULL #> #> $knitr$opts_hooks #> NULL #> #> $knitr$opts_template #> NULL #> #> #> $pandoc #> $pandoc$to #> [1] "gfm" #> #> $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" #> #> #> $keep_md #> [1] FALSE #> #> $clean_supporting #> [1] FALSE #> #> $df_print #> [1] "default" #> #> $pre_knit #> function(input, ...) { #> #> # I don't know why the pre_knit hook operates on the **original** input #> # instead of the to-be-knitted (post-spinning) input, but I need to #> # operate on the latter. So I brute force the correct path. #> # This is a no-op if input starts as `.Rmd`. #> 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) #> } #> <bytecode: 0x556175b2d150> #> <environment: 0x556175b4a350> #> #> $post_knit #> NULL #> #> $pre_processor #> NULL #> #> $intermediates_generator #> NULL #> #> $post_processor #> NULL #> #> $on_exit #> function() { #> if (is.function(base)) base() #> if (is.function(overlay)) overlay() #> } #> <bytecode: 0x5561732410c8> #> <environment: 0x55617315b060> #> #> attr(,"class") #> [1] "rmarkdown_output_format"