reprex/ 0000755 0001762 0000144 00000000000 14547723414 011572 5 ustar ligges users reprex/NAMESPACE 0000644 0001762 0000144 00000000654 14310727461 013010 0 ustar ligges users # Generated by roxygen2: do not edit by hand
export(reprex)
export(reprex_addin)
export(reprex_clean)
export(reprex_document)
export(reprex_html)
export(reprex_invert)
export(reprex_locale)
export(reprex_r)
export(reprex_render)
export(reprex_rescue)
export(reprex_rtf)
export(reprex_selection)
export(reprex_slack)
import(fs)
import(rlang)
importFrom(glue,glue)
importFrom(glue,glue_collapse)
importFrom(lifecycle,deprecated)
reprex/LICENSE 0000644 0001762 0000144 00000000054 14547644752 012605 0 ustar ligges users YEAR: 2024
COPYRIGHT HOLDER: reprex authors
reprex/README.md 0000644 0001762 0000144 00000012233 14547646710 013055 0 ustar ligges users # reprex
[](https://cran.r-project.org/package=reprex)
[](https://github.com/tidyverse/reprex/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/tidyverse/reprex?branch=main)
## Overview
Prepare reprexes for posting to [GitHub
issues](https://docs.github.com/issues/tracking-your-work-with-issues/about-issues),
[StackOverflow](https://stackoverflow.com/questions/tagged/r), in Slack [messages](https://slack.com/intl/en-ca/help/articles/201457107-Send-and-read-messages) or [snippets](https://slack.com/intl/en-ca/help/articles/204145658-Create-a-snippet), or even to paste into PowerPoint or Keynote slides.
What is a `reprex`? It’s a **repr**oducible **ex**ample, as coined by
Romain Francois in a tweet from 2014.
Given R code on the clipboard, selected in RStudio, as an expression
(quoted or not), or in a file …
- run it via `rmarkdown::render()`,
- with deliberate choices re: `render()` arguments, knitr options, and
Pandoc options.
Get resulting runnable code + output as
- Markdown, suitable for GitHub or Stack Overflow or Slack, or as
- R code, augmented with commented output, or as
- Plain HTML or (experimental) Rich Text
The result is returned invisibly, written to a file and, if possible, placed on the clipboard.
Preview an HTML version in RStudio viewer or default browser.
## Installation
Install from CRAN:
``` r
install.packages("reprex")
```
or get a development version from GitHub:
``` r
# install.packages("pak")
pak::pak("tidyverse/reprex")
```
On Linux, you probably want to install
[xclip](https://github.com/astrand/xclip) or
[xsel](https://www.vergenet.net/~conrad/software/xsel/), so reprex can
access the X11 clipboard. This is 'nice to have', but not mandatory. The
usual `sudo apt-get install` or `sudo yum install` installation methods
should work for both xclip and xsel.
## Usage
Let’s say you copy this code onto your clipboard (or, on RStudio Server or Cloud, select it):
(y <- 1:4)
mean(y)
Then call `reprex()`, where the default target venue is GitHub:
``` r
reprex()
```
A nicely rendered HTML preview will display in RStudio's Viewer (if
you’re in RStudio) or your default browser otherwise.

The relevant bit of GitHub-flavored Markdown is ready to be pasted from
your clipboard (on RStudio Server or Cloud, you will need to copy this yourself):
``` r
(y <- 1:4)
#> [1] 1 2 3 4
mean(y)
#> [1] 2.5
```
Here’s what that Markdown would look like rendered in a GitHub issue:
``` r
(y <- 1:4)
#> [1] 1 2 3 4
mean(y)
#> [1] 2.5
```
Anyone else can copy, paste, and run this immediately.
In addition to GitHub, this Markdown also works on Stack Overflow and Discourse. Those venues can be formally requested via `venue = "so"` and `venue = "ds"`, but they are just aliases for `venue = "gh"`.
Instead of reading from the clipboard, you can:
- `reprex(mean(rnorm(10)))` to get code from expression.
- `reprex(input = "mean(rnorm(10))\n")` gets code from character
vector (detected via length or terminating newline). Leading prompts
are stripped from input source: `reprex(input = "> median(1:3)\n")`
produces same output as `reprex(input = "median(1:3)\n")`
- `reprex(input = "my_reprex.R")` gets code from file
- Use one of the RStudio add-ins to use the selected text or current
file.
But wait, there’s more\!
- Get slightly different Markdown, optimized for Slack messages, with
`reprex(..., venue = "slack")`.
- Get a runnable R script, augmented with commented output, with
`reprex(..., venue = "R")`. This is useful for Slack code snippets, email,
etc.
- Get html with `reprex(..., venue = "html")`. Useful for sites that don't
support Markdown.
- Prepare (un)rendered, syntax-highlighted code snippets to paste into
Keynote or PowerPoint, with `reprex(..., venue = "rtf")`. This
feature is still experimental; see the [associated article](https://reprex.tidyverse.org/articles/articles/rtf.html) for more.
- By default, figures are uploaded to [imgur.com](https://imgur.com/)
and the resulting URL is dropped into an inline image tag.
- If you really need to reprex in a specific directory, use the `wd`
argument. For example, `reprex(wd = ".")` requests the current
working directory.
- Append session info via `reprex(..., session_info = TRUE)`.
- Get clean, runnable code from wild-caught reprexes with
- `reprex_invert()` = the opposite of `reprex()`
- `reprex_clean()`, e.g. when you copy/paste from GitHub or Stack
Overflow
- `reprex_rescue()`, when you’re dealing with copy/paste from R
Console
reprex/man/ 0000755 0001762 0000144 00000000000 14547645470 012352 5 ustar ligges users reprex/man/reprex-package.Rd 0000644 0001762 0000144 00000003201 14547646515 015534 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/reprex-package.R
\docType{package}
\name{reprex-package}
\alias{reprex-package}
\title{reprex: Prepare Reproducible Example Code via the Clipboard}
\description{
\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}}
Convenience wrapper that uses the 'rmarkdown' package to render small snippets of code to target formats that include both code and output. The goal is to encourage the sharing of small, reproducible, and runnable examples on code-oriented websites, such as \url{https://stackoverflow.com} and \url{https://github.com}, or in email. The user's clipboard is the default source of input code and the default target for rendered output. 'reprex' also extracts clean, runnable R code from various common formats, such as copy/paste from an R session.
}
\seealso{
Useful links:
\itemize{
\item \url{https://reprex.tidyverse.org}
\item \url{https://github.com/tidyverse/reprex}
\item Report bugs at \url{https://github.com/tidyverse/reprex/issues}
}
}
\author{
\strong{Maintainer}: Jennifer Bryan \email{jenny@posit.co} (\href{https://orcid.org/0000-0002-6983-2759}{ORCID})
Authors:
\itemize{
\item Jim Hester (\href{https://orcid.org/0000-0002-2739-7082}{ORCID})
\item David Robinson \email{admiral.david@gmail.com}
\item Hadley Wickham \email{hadley@posit.co} (\href{https://orcid.org/0000-0003-4757-117X}{ORCID})
\item Christophe Dervieux \email{cderv@posit.co} (\href{https://orcid.org/0000-0003-4474-2498}{ORCID})
}
Other contributors:
\itemize{
\item Posit Software, PBC [copyright holder, funder]
}
}
\keyword{internal}
reprex/man/reprex_locale.Rd 0000644 0001762 0000144 00000007047 14310727461 015462 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/reprex-locale.R
\name{reprex_locale}
\alias{reprex_locale}
\title{Render a reprex in a specific locale}
\usage{
reprex_locale(..., language = "en", locale = NULL)
}
\arguments{
\item{...}{Inputs passed through to \code{\link[=reprex]{reprex()}}.}
\item{language}{A string specifying the preferred language for messages. It
is enacted via the \code{LANGUAGE} environment variable, for the duration of the
\code{reprex()} call. Examples: \code{"en"} for English and \code{"fr"} for French. See
Details for more.}
\item{locale}{A named character vector, specifying aspects of the locale, in
the \code{\link[=Sys.setlocale]{Sys.setlocale()}} sense. It is enacted by setting one or more
environment variables, for the duration of the \code{reprex()} call. See Details
for more.}
}
\value{
Character vector of rendered reprex, invisibly.
}
\description{
Render a \code{\link[=reprex]{reprex()}}, with control over the localization of error messages and
aspects of the locale. Note that these are related but distinct issues!
Typical usage is for someone on a Spanish system to create a reprex that is
easier for an English-speaking audience to follow.
}
\section{\code{language}}{
Use the \code{language} argument to express the preferred language of error
messages. The output of \code{dir(system.file(package = "translations"))} may
provide some helpful ideas. The \code{language} should generally follow "XPG
syntax": a two-letter language code, optionally followed by other modifiers.
Examples: \code{"en"}, \code{"de"}, \code{"en_GB"}, \code{"pt_BR"}.
}
\section{\code{locale}}{
Use the \code{locale} argument only if you want to affect something like how
day-of-the-week or month is converted to character. You are less likely to
need to set this than the \code{language} argument. You may have more success
setting specific categories, such as \code{"LC_TIME"}, than multi-category
shortcuts like \code{"LC_ALL"} or \code{"LANG"}. The \code{locale} values must follow the
format dictated by your operating system and the requested locale must be
installed. On *nix systems, \code{locale -a} is a good way to see which locales
are installed. Note that the format for \code{locale} and \code{language} are different
from each other on Windows.
Examples: \code{"en_CA.UTF-8"} (macOS), \code{"French_France.1252"} (Windows).
}
\examples{
\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")
)
}
}
\seealso{
\itemize{
\item The \href{https://www.gnu.org/software/libc/manual/html_node/Locale-Names.html}{Locale Names}
section of the GNU C docs, for more about XPG syntax
\item The \href{https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Internationalization}{Internationalization and Localization}
section of the R Installation and Administration manual
}
}
reprex/man/reprex_addin.Rd 0000644 0001762 0000144 00000004651 14547654641 015313 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/reprex-addin.R
\name{reprex_addin}
\alias{reprex_addin}
\alias{reprex_selection}
\title{Render a reprex, conveniently}
\usage{
reprex_addin()
reprex_selection(venue = getOption("reprex.venue", "gh"))
}
\arguments{
\item{venue}{Character. Must be one of the following (case insensitive):
\itemize{
\item "gh" for \href{https://github.github.com/gfm/}{GitHub-Flavored Markdown}, the
default
\item "r" for a runnable R script, with commented output interleaved. Also useful
for \href{https://slack.com/intl/en-ca/slack-tips/share-code-snippets}{Slack code snippets};
select "R" from the "Type" drop-down menu to enjoy nice syntax
highlighting.
\item "rtf" for
\href{https://en.wikipedia.org/wiki/Rich_Text_Format}{Rich Text Format}
(not supported for un-reprexing)
\item "html" for an HTML fragment suitable for inclusion in a larger HTML
document (not supported for un-reprexing)
\item "slack" for pasting into a Slack message. Optimized for people who opt out
of Slack's WYSIWYG interface. Go to
\strong{Preferences > Advanced > Input options} and select "Format messages with
markup". (If there is demand for a second Slack venue optimized for use
with WYSIWYG, please open an issue to discuss.)
\item "so" for
\href{https://stackoverflow.com/editing-help#syntax-highlighting}{Stack Overflow Markdown}.
Note: this is just an alias for "gh", since Stack Overflow started to
support CommonMark-style fenced code blocks in January 2019.
\item "ds" for Discourse, e.g.,
\href{https://community.rstudio.com}{community.rstudio.com}. Note: this is
currently just an alias for "gh".
}}
}
\description{
\code{reprex_addin()} opens an \href{https://shiny.rstudio.com/articles/gadgets.html}{RStudio gadget} and
\href{http://rstudio.github.io/rstudioaddins/}{addin} that allows you to say
where the reprex source is (clipboard? current selection? active file?
other file?) and to control a few other arguments. Appears as "Render
reprex" in the RStudio Addins menu.
\code{reprex_selection()} is an
\href{http://rstudio.github.io/rstudioaddins/}{addin} that reprexes the current
selection, optionally customised by options. Appears as "Reprex selection"
in the RStudio Addins menu. Heavy users might want to create a keyboard
shortcut (\verb{https://support.posit.co/hc/en-us/articles/206382178-Customizing-Keyboard-Shortcuts}).
Suggested shortcut: Cmd + Shift + R (macOS) or Ctrl + Shift + R (Windows).
}
reprex/man/figures/ 0000755 0001762 0000144 00000000000 14310727461 014003 5 ustar ligges users reprex/man/figures/lifecycle-defunct.svg 0000644 0001762 0000144 00000002424 14403224513 020104 0 ustar ligges users
reprex/man/figures/lifecycle-maturing.svg 0000644 0001762 0000144 00000002430 14403224513 020277 0 ustar ligges users
reprex/man/figures/README-viewer-screenshot.png 0000644 0001762 0000144 00000113367 14102672630 021127 0 ustar ligges users PNG
IHDR X Ɖ gAMA a cHRM z&