All Projects → tidyverse → Reprex

tidyverse / Reprex

Licence: other
Render bits of R code for sharing, e.g., on GitHub or StackOverflow.

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Reprex

ReproducibleScience
Short course on reproducible science: what, why, how
Stars: ✭ 23 (-95.84%)
Mutual labels:  rmarkdown, reproducibility
Reproducibilidad
Reproducible Science: what, why, how
Stars: ✭ 39 (-92.95%)
Mutual labels:  rmarkdown, reproducibility
Sacred
Sacred is a tool to help you configure, organize, log and reproduce experiments developed at IDSIA.
Stars: ✭ 3,678 (+565.1%)
Mutual labels:  reproducibility
Rmdformats
HTML output formats for RMarkdown documents
Stars: ✭ 492 (-11.03%)
Mutual labels:  rmarkdown
Vscode R
R Extension for Visual Studio Code (execution, snippet, lint, R documantation, R Markdown)
Stars: ✭ 445 (-19.53%)
Mutual labels:  rmarkdown
Rebound
Command-line tool that instantly fetches Stack Overflow results when an exception is thrown
Stars: ✭ 3,763 (+580.47%)
Mutual labels:  stackoverflow
Mimicry
[CVPR 2020 Workshop] A PyTorch GAN library that reproduces research results for popular GANs.
Stars: ✭ 458 (-17.18%)
Mutual labels:  reproducibility
Stack Overflow Import
Import arbitrary code from Stack Overflow as Python modules.
Stars: ✭ 3,480 (+529.29%)
Mutual labels:  stackoverflow
Labnotebook
LabNotebook is a tool that allows you to flexibly monitor, record, save, and query all your machine learning experiments.
Stars: ✭ 526 (-4.88%)
Mutual labels:  reproducibility
Wdl
Workflow Description Language - Specification and Implementations
Stars: ✭ 438 (-20.8%)
Mutual labels:  reproducibility
Jupytext
Jupyter Notebooks as Markdown Documents, Julia, Python or R scripts
Stars: ✭ 4,969 (+798.55%)
Mutual labels:  rmarkdown
Papaja
papaja (Preparing APA Journal Articles) is an R package that provides document formats to produce complete APA manuscripts from RMarkdown-files (PDF and Word documents) and helper functions that facilitate reporting statistics, tables, and plots.
Stars: ✭ 422 (-23.69%)
Mutual labels:  rmarkdown
Summarytools
R Package to Quickly and Neatly Summarize Data
Stars: ✭ 390 (-29.48%)
Mutual labels:  rmarkdown
Scoold
A Stack Overflow clone for teams (self-hosted)
Stars: ✭ 463 (-16.27%)
Mutual labels:  stackoverflow
Datmo
Open source production model management tool for data scientists
Stars: ✭ 334 (-39.6%)
Mutual labels:  reproducibility
Rrtools
rrtools: Tools for Writing Reproducible Research in R
Stars: ✭ 508 (-8.14%)
Mutual labels:  reproducibility
Rmarkdown Cookbook
R Markdown Cookbook. A range of tips and tricks to make better use of R Markdown.
Stars: ✭ 324 (-41.41%)
Mutual labels:  rmarkdown
Open Solution Home Credit
Open solution to the Home Credit Default Risk challenge 🏡
Stars: ✭ 397 (-28.21%)
Mutual labels:  reproducibility
Gtsummary
Presentation-Ready Data Summary and Analytic Result Tables
Stars: ✭ 450 (-18.63%)
Mutual labels:  reproducibility
Workflowr
Organize your project into a research website
Stars: ✭ 551 (-0.36%)
Mutual labels:  rmarkdown

reprex

CRAN_Status_Badge R-CMD-check Codecov test coverage lifecycle

Overview

Prepare reprexes for posting to GitHub issues, StackOverflow, in Slack messages or snippets, or even to paste into PowerPoint or Keynote slides. What is a reprex? It’s a reproducible example, as coined by Romain Francois.

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:

install.packages("reprex")

or get a development version from GitHub:

devtools::install_github("tidyverse/reprex")

On Linux, you probably want to install xclip or 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:

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:

(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 for more.

  • By default, figures are uploaded to 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

Code of Conduct

Please note that the reprex project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].