{"id":14068712,"url":"https://github.com/tidyverse/reprex","last_synced_at":"2025-07-30T04:32:18.159Z","repository":{"id":1892902,"uuid":"41376769","full_name":"tidyverse/reprex","owner":"tidyverse","description":"Render bits of R code for sharing, e.g., on GitHub or StackOverflow.","archived":false,"fork":false,"pushed_at":"2024-09-10T22:40:46.000Z","size":23035,"stargazers_count":740,"open_issues_count":17,"forks_count":81,"subscribers_count":19,"default_branch":"main","last_synced_at":"2024-10-28T23:01:33.598Z","etag":null,"topics":["github","r","reproducibility","rmarkdown","stackoverflow"],"latest_commit_sha":null,"homepage":"https://reprex.tidyverse.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tidyverse.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-25T17:06:45.000Z","updated_at":"2024-10-26T01:35:22.000Z","dependencies_parsed_at":"2024-01-24T05:47:37.503Z","dependency_job_id":"1608fa89-3f44-4f09-999e-ba01519bf78d","html_url":"https://github.com/tidyverse/reprex","commit_stats":{"total_commits":721,"total_committers":27,"mean_commits":"26.703703703703702","dds":0.3148404993065187,"last_synced_commit":"b904f73989583e66cb02fd0199df6cede5be1c3f"},"previous_names":["jennybc/reprex"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidyverse%2Freprex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidyverse%2Freprex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidyverse%2Freprex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidyverse%2Freprex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tidyverse","download_url":"https://codeload.github.com/tidyverse/reprex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228082366,"owners_count":17866607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","r","reproducibility","rmarkdown","stackoverflow"],"created_at":"2024-08-13T07:06:21.704Z","updated_at":"2024-12-04T09:31:18.485Z","avatar_url":"https://github.com/tidyverse.png","language":"R","readme":"# reprex \u003ca href=\"https://reprex.tidyverse.org\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" alt = \"\"/\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN\\_Status\\_Badge](https://www.r-pkg.org/badges/version/reprex)](https://cran.r-project.org/package=reprex)\n[![R-CMD-check](https://github.com/tidyverse/reprex/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidyverse/reprex/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/tidyverse/reprex/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/reprex?branch=main)\n\u003c!-- badges: end --\u003e\n\n## Overview\n\nPrepare reprexes for posting to [GitHub\nissues](https://docs.github.com/issues/tracking-your-work-with-issues/about-issues),\n[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.\nWhat is a `reprex`? It’s a **repr**oducible **ex**ample, as coined by\nRomain Francois in a tweet from 2014.\n\n\u003ca href=\"https://media.giphy.com/media/fdLR6LGwAiVNhGQNvf/giphy.gif\"\u003e\u003cimg src=\"man/figures/help-me-help-you.png\" align=\"right\" /\u003e\u003c/a\u003e\n\nGiven R code on the clipboard, selected in RStudio, as an expression\n(quoted or not), or in a file …\n\n  - run it via `rmarkdown::render()`,\n  - with deliberate choices re: `render()` arguments, knitr options, and\n    Pandoc options.\n\nGet resulting runnable code + output as\n\n  - Markdown, suitable for GitHub or Stack Overflow or Slack, or as\n  - R code, augmented with commented output, or as\n  - Plain HTML or (experimental) Rich Text\n\nThe result is returned invisibly, written to a file and, if possible, placed on the clipboard.\nPreview an HTML version in RStudio viewer or default browser.\n\n## Installation\n\nInstall from CRAN:\n\n``` r\ninstall.packages(\"reprex\")\n```\n\nor get a development version from GitHub:\n\n``` r\n# install.packages(\"pak\")\npak::pak(\"tidyverse/reprex\")\n```\n\nOn Linux, you probably want to install\n[xclip](https://github.com/astrand/xclip) or\n[xsel](https://www.vergenet.net/~conrad/software/xsel/), so reprex can\naccess the X11 clipboard. This is 'nice to have', but not mandatory. The\nusual `sudo apt-get install` or `sudo yum install` installation methods\nshould work for both xclip and xsel.\n\n## Usage\n\nLet’s say you copy this code onto your clipboard (or, on RStudio Server or Cloud, select it):\n\n    (y \u003c- 1:4)\n    mean(y)\n\nThen call `reprex()`, where the default target venue is GitHub:\n\n``` r\nreprex()\n```\n\nA nicely rendered HTML preview will display in RStudio's Viewer (if\nyou’re in RStudio) or your default browser otherwise.\n\n![](man/figures/README-viewer-screenshot.png)\n\nThe relevant bit of GitHub-flavored Markdown is ready to be pasted from\nyour clipboard (on RStudio Server or Cloud, you will need to copy this yourself):\n\n    ``` r\n    (y \u003c- 1:4)\n    #\u003e [1] 1 2 3 4\n    mean(y)\n    #\u003e [1] 2.5\n    ```\n\nHere’s what that Markdown would look like rendered in a GitHub issue:\n\n``` r\n(y \u003c- 1:4)\n#\u003e [1] 1 2 3 4\nmean(y)\n#\u003e [1] 2.5\n```\n\nAnyone else can copy, paste, and run this immediately.\n\nIn 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\"`.\n\nInstead of reading from the clipboard, you can:\n\n  - `reprex(mean(rnorm(10)))` to get code from expression.\n\n  - `reprex(input = \"mean(rnorm(10))\\n\")` gets code from character\n    vector (detected via length or terminating newline). Leading prompts\n    are stripped from input source: `reprex(input = \"\u003e median(1:3)\\n\")`\n    produces same output as `reprex(input = \"median(1:3)\\n\")`\n\n  - `reprex(input = \"my_reprex.R\")` gets code from file\n\n  - Use one of the RStudio add-ins to use the selected text or current\n    file.\n\nBut wait, there’s more\\!\n\n  - Get slightly different Markdown, optimized for Slack messages, with\n    `reprex(..., venue = \"slack\")`.\n\n  - Get a runnable R script, augmented with commented output, with\n    `reprex(..., venue = \"R\")`. This is useful for Slack code snippets, email,\n    etc.\n\n  - Get html with `reprex(..., venue = \"html\")`. Useful for sites that don't\n    support Markdown.\n\n  - Prepare (un)rendered, syntax-highlighted code snippets to paste into\n    Keynote or PowerPoint, with `reprex(..., venue = \"rtf\")`. This\n    feature is still experimental; see the [associated article](https://reprex.tidyverse.org/articles/articles/rtf.html) for more.\n\n  - By default, figures are uploaded to [imgur.com](https://imgur.com/)\n    and the resulting URL is dropped into an inline image tag.\n\n  - If you really need to reprex in a specific directory, use the `wd`\n    argument. For example, `reprex(wd = \".\")` requests the current\n    working directory.\n    \n  - Append session info via `reprex(..., session_info = TRUE)`.\n\n  - Get clean, runnable code from wild-caught reprexes with\n    \n      - `reprex_invert()` = the opposite of `reprex()`\n      - `reprex_clean()`, e.g. when you copy/paste from GitHub or Stack\n        Overflow\n      - `reprex_rescue()`, when you’re dealing with copy/paste from R\n        Console\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidyverse%2Freprex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftidyverse%2Freprex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidyverse%2Freprex/lists"}