FAQ: What's a reproducible example (`reprex`) and how do I do one?

faq

#1

Why reprex?

Getting unstuck is hard. Your first step here is usually to create a reprex, or reproducible example. The goal of a reprex is to package your code, and information about your problem so that others can run it and feel your pain. Then, hopefully, folks can more easily provide a solution.

What's in a Reproducible Example?

Parts of a reproducible example:

  1. background information - Describe what you are trying to do. What have you already done?
  2. complete set up - include any library() calls and data to reproduce your issue.
    data for a reprex: Here's a discussion on setting up data for a reprex
  3. make it run - include the minimal code required to reproduce your error on the data provided.
    People should be able to copy and paste your code chunk and get the same error.
    How do I format my text so it has nice code chunks?
  4. minimal - strip away everything that is not directly related to your problem. This usually involves creating a much smaller and simpler set of code and data compared to that which created your issue.

Use the reprex-package to Build Your Reproducible Example

When creating a reprex by hand, it’s easy to accidentally miss something that means your code can’t be run on someone else’s computer. Avoid this problem by using the reprex-package.
The reprex package will save effort for you and others who want to help.

Personal and Private Information

Users should not share personal or protected information in topic threads or reprex data.
What if you need to share contact info or an ip, or discuss data for a reprex related to a protected dataset? What if you see a violation of this policy? Check out Personally Identifiable & Protected Information Guide guide and our Privacy Policy


Beginners - Step by Step Help

Help asking R-related questions (not specific to the reprex-package)

Background on the reprex-package


Kable message: multiple "over-long path length"
Frequently Asked Questions
Error saving file with garbled error message
Flashing/disappearing imageOutput
First shiny app - error message - missing argument
Help needed: non-numeric argument to binary operator
Logistic linear regression failed - wants to know other model which suits this
Multiply matrix numeric with matrix no numeric
the dataset requirements using fable--Tidy forecasting in R
Track down error in R
Figure Caption in R markdown
Geom_bar + facet_grid not behaving as expected
How do i use the ranking function Row_number with multiple conditions in R
Ggplot troubleshoot: Error: Aesthetics must be either length 1 or the same as the data (24): x, y, fill
In R, how do I code "only show the first 2 words" of an output?
Plot truncates on x-axis - advice to avoid this
I need help to add the title to a MCA factor map plot
Converting a continuous variable to a discrete value for regression
Reprex vs. reprex-package discussions
How can I plot data in a CSV file after uploading it using R shiny? I have used the code below and seems not working for me
Plotting quantile regression coefficients
Error in keras_model_sequential() : file name conversion problem -- name too long?
Problems with dcc function of the treeclim package
How to Read Large JSON file in R?
Unable to import Excel workbook
Degree of vertex
How to work on dataframes with different lengths
Plot() does only show Residuals vs. Fitted, but not other diagnostic plots; par(mfrow=c(2,2)) already applied
Forecasting - Combination of methods
Modeling bimodal curves with smsn.mix()
EasyMARK and Maker.CH problems
Area weighted seasonal cummulative precipitation extraction based on crop yeild area file
R does not display output
Error in the predict function
RStudio breaks on FreeBSD: "TypeError: undefined is not an object (evaluating 'window.desktopHooks.notifyRCrashed')"
How to use crawler with Rcrawler for automatic download in r?
Relabel and merge the fasta files
How to deal with character(0) in R
R version 3.5.0 Beta
Histograms with loops
r equivalent of sas put statement
total data is double
need help with Haversine function
String match in R
Stranger things
Determining peak of normal distributed data
How to make function which can read an argument without any gap or comma?
Reading RDS file format from HDFS using SparklyR package using Microsoft R Open
Calculating a mean from a specific population within a data set
How to separate title from desc (scraping data IMDB-Coming Soon Movie)
What is wrong with this tidy eval function?
Help with function convert.inp in RMark
A r code execution error about fuction "text"
StatBin requires a continuous x variable the x variable is discrete
Reproducing results from Cameroon & Trivadi book
Circle in ggplot2
Plotting over an existing plot with ggplot2
With monthly measurements points
Refresh query on every new entry in database and instant response on my plot
"closure" is not subsettable
Demeaning / Mean-Centering of certain values only
Wavelet Coherence
Selecting suitable supervised learning algorithm
Ggplot not showing all dates on x asis even when forced
Error in ANOVA contrast commands
Plot large data in R
gvisMotionChart From googleVis is not working any suggestion?
Problem with applying function to a dataframe
Data frame error - "replacement has 4 rows, data has...."
How to apply corrr::correlate by group?
GGMAP : Unable to create points on the map
Writing Greek in Rstudio
Single and double Quotes at SQLQuery connected to Presto
Empty spaces instead of wormplots (wp() function in GAMLSS module)
A cry for help with boot()
How do I make an ad hoc smoothing parameter in the Adehabitat HR package?
Recursive calcs on timeseries
Cex installation problem
Deploying Error, No problem a few days ago
Changing colour of bars in chart on ggplot
Error in UseMethod(TermDocumentMatrix, x), Mail Base
renderPlotly creates lines between points when combined with ggmap
(not so) stranger things
Finding all Universal Combinations in an Occurrence Matrix
Problem with Clustered SE's
Ifelse with mutiple actions
Need Help in Running the codes
Importing xml in R
Merging survey data with geographic data
Rstudio in Linux
BLAS/LAPACK routine 'DLASCL' gave error code -4
Programming Help
Tags$img problem with srcset
FAQ: How do I edit my Topic or Post?
Importing Data with API
Rounding and piping
Aligning tables in the center?
Chunk of Python code continues to run after clicking on red square
Subsetting dataset to include numerical values in a column
Bookdown: Blank output files (basically the output in HTML is blank an no RMD data is shown)
Add a Zoom on my plot
Pink dots appear in files and unable to save files intermittently MacOS High Sierra
Roxygen2 does not work with R 3.5.0
Inconsistent digits beyond decimal when combined with scientific notation kableExtra table R markdown
Find the elements that sums closest to zero value
System call within R shiny
Matrices x Vector multiplication using R script
Creating a new column with breaks
Plotly plot showing in viewer pane instead of R notebook
How to customise colours to specific things
Rcpp can't find sugar functions
Problem with "bnlearn" package & string elements table by reading with excel (or readxl...)
Can't add images to R Markdown file
R HELP! PSO Package - "Error during wrapup: incorrect number of dimensions
Rstudio and Linux Ubuntu18.04
Debugger stops at incorrect line
Ggplot2: How to specify x labels in a datetime data and two segment lines
Beginner question
How to average/mean variables in R based on the level of another variable (and save this as a new variable)?
FAQ: Homework Policy
Installing readxl, tidyveerse and devtools
Get Google trends data - problem with output
Ggplot doesn't take an Empty dataset what to do?
A Durbin-Watson test question
Could not find svmRadial function
Problem with summarize in r
Dplyr summarise categorial variable that appears multiple times
Problem with "jitter"
Sqldf questions in R studio
Problem in 'matplot' function
Create Volcano Plot
Keras Input~Output dimensions
Error Preventing Knitting
Plot(table) in googleVis
Transforming daily data in wide format to long
In pearson correlation if the value comes in complex fromat (1.346045e-17) then what it means
Error: cannot allocate vector of size 196.1 Mb In addition: Warning message:
gganimate with lines.
Mixed GLMM Model - Issues with using weights argument
Transposing/Reshaping Data Frame
Error in gzfile(path.expand(tarfile), "rb") : cannot open the connection In addition: Warning message: In gzfile(path.expand(tarfile), "rb") : cannot open compressed file 'NA', probable reason 'Permission denied'
Rstudio to hadoop cluster connection to read hive database tables
Slowing of ggplot2 and plotly
Linking CRSP and Compustat in R
Convert pair(1L,2L) to pair(1,2)
Connecting R with Database | Large Query Result
Switch beetweeen tabItems
Autolayer() deleted from ggplot2 and forecast package - alternatives?
Read string from array
How to assign categorical variables to specific rows of data
Facing problem while writing the R code
Need help to convert data to xml
An important bar in the graph
How to assign a letter grade to the marks while doing the results analysis for examination results of a class?
How to get percentage and then create a plot from a given output
Ggmap: how to highlight city limits?
Downloading CHIRPs rainfall data
Create Volcano Plot
Regarding adding bar labels at the top of each bar in ggplot() in Rstudio
Problems installing packages between CRAN and file location
Error: `by` can't contain join column `shopper_id` which is missing from LHS - But it is!
Helping with the code, it doesn't work without any error
Adding column based on other column
Loading ECG binary .dat files
Str_replace_all - how to use
I want to use ggplot2 and reshape to draw multiple densities on the same plot, tried this is my code and error,
Importing data from table using Shiny
Building Dendrogram using NormalizeMets
Shiny Tutorial Lesson 5: How to add counties name on the map
Problem with non-ASCII characters in DocumentTermMatrix
Error: no applicable method for 'mutate_' applied to an object of class "character"
Copy array & keep data formats
Collecting tweets based on csv file with point coordinates
Document term matrix in XGBoost classifier
How to Ignore one of the factors in a Column
Combine 3 CSV columns into a variable
Define a new column for genre of the movie
How to Create Textbox in Server
I have to insert 0 into NA and missing values in a csv file
hclust using your own results
How to use tidyverse to group columns
Advice for Improving Community Response to Modeling and Machine Learning Topics
Gmailr formatting
Error in $: object of type 'closure' is not subsettable
Generate a data frame from many xml files
Need Help : group_by and summarize_each
Data Frame: join a groupby with a new column as a new index
Tidyverse ggplot() help: How to segment each column in the geom_bar()
LEA Help Excel File Layout
R : dynamic plot value and x axis value for line chart
Selecting data in a range
Xml2 package installation issues - pkg-config PATH help
Problems with 'select' function, unknown column rlang error appears
Read.table with no header
RStudio GUI crash by use of manipulateWidget function
Multiple bounded dichotomous choice
Problem with titles and subplot
Arguments imply differing number of rows
Subsetting Data
I want to create a new variable with logical operators
Python TypeError
Error in eval(predvars, data, env) : object 'avg' not found
Effect size in forest plot using metafor
Flextable output in RMarkDown
background color in data table
R session aborted while running autoencoder
Support Vector Machine - Can't create an additional predicted value for my data set
Mutate_at() not ignoring NA values with janitor functions
How to track each unique customer's purchases over time
Which library to find the range of parameters with highest result?
Can R Studio show me which line number in my code was called last when an error occurs?
Data prediction for missing data
Passing ggplot2 options to a custom function
Exporting file in CSV gives junk rows using write.csv / write_csv
Unable to do a group_by
Creating a shiny app UI for R model
Geom_text - Math expression label annotation - color, parsing, and subgraph labeling problems
Load a retrained keras mobilenet model
How to anchor for the omic circos plot using a set of genes?
DPLYR not recognizing a column that is in my dataframe
Data wrangling and line graphs
Knit to HTML Error
Retrieving stored ARIMA model using REACTIVE function -- Error in as.vector: cannot coerce type 'closure' to vector of type 'character
Selecting rows from a data
Date format changes while using levels in R
Image classification error in Rstudio for keras
Go to a different Page in shiny by Clicking on the link on an image
'data' must be 2-dimensional (e.g. data frame or matrix) while using DT format R Shiny
Shiny app works fine locally, error when publishing to Shiny server
Beginners difficulties making graphs
Create character strings with a certain length from a data frame
Revamping string elements
Control chart in R
Code error while running with the dplyr
Create scatterplot with multiple variables
How can I generate a GG Diagram in R Studio?
Query Data from Snowflake Database
How to get a file downloaded from an .aspx website after completing a form
Filter from a dataframe and create another dataframe
Non-R code blocks not executable in Rmarkdown
Pascal triangle
Ignore this, I need to update the question
Convert variables to 1 and 0
How can I write 3 blocks of code to 3 files when the blocks of code and the file names are in different lists
Error subset data .txt
How to add a counter to each group in dplyr
How to add a counter to each group in dplyr
Changing Base R code to dplyr/sparklyr
Locator function getting stuck
Ignore regular expression in grep pattern
Viewing corrplot
R^2 of regressed line fitted through origin
Error: Columns `x`, `y` must be 1d atomic vectors or lists
Coming up with Example/Dummy Datasets for a REPREX
Error in .cbind.ts(list(...), .makeNamesTs(...), dframe = FALSE, union = TRUE) :
ggplot position dodge with position stack
!self$finished is not TRUE
2 groups - multiple variables
Data.Table method of doing the following:
Subject package
Rshiny throws error after publish the app
Import multiple shapefiles and export a .csv file
Error message popped up
ggplot choropleth map merging trouble
Using n_distinct
K Cluster Method
Ggplots appearing as default R plots
<!DOCTYPE html> in rendered Rmd document
Second order Response Surface
R script issues
Create column for T+0
Equivalent to switch in tidyverse running a list of commands
Error message popped up
I need a script to perform a regression in R
How to create a global attribute that is itself an array
Need to import data from a .csv file. Turn into time series and plot the time series as well as the linear regression
Does Merge work different within a created Function?
KNN imputation and error messages
Result of function into dataframe. R beginner, first post
Stringsasfactors doesn't work!
How may I add the amount of variables (e.g. n=5) of each data.frame on the x-axes to the ggplot?
Does Merge work different within a created Function?
Data frame not inserted the right value.
Ggsave aspect ratio / whitespace (use case: favicon for blogdown)
Separating columns containing descriptive and capture-recapture data
Improve the speed
Forest plot study labeling
Create vector from file names in folder?
RStudio crashes when doing lm
How to merge the two different data frame column with row matching?
Plots crash while exporting as .svg
<simpleError in is(obj, "ore.frame"): could not find function "is">
Filter bigram list from a dataframe
How to make a non-stacked bar plot with one column table?
Get column from table
Error with plotting graphs for regression models
Text concatenation
Problem with using optim
Warning messages: All formats failed to parse. No formats found
R does not find a variable
Error in vinecopula
Trying to create balanced train set with SMOTE
Line of best fit
web scrapping data from webpage and save in data frame
Prepping and importing time series data (for noobs)
Write to CSV, column of string values
R studio: Error in tabular
identifying exact or near duplicate names in a dataset
NAs introduced by coercionError in mutate_impl(.data, dots) : Column `XY` must be length 96 (the number of rows) or one, not 8
I am having trouble loading lm or the regression program onto R
How to change icon position using bsButton
Shiny multiplying graph whem click in textInput
Help with filter and select function
Is there someone who has used bnosac/image YOLO package
Ggplot legend error
I'm having trouble using lm function in my code. How can I debug this?
ActionButton with eventReactive
How to add two sub-columns in one (Concat) using datatable (DT) in R Markdown/Shiny?
Suggestions required
Permutation with two vectors
Writing code to do word counts for a large corpus
Performing GLMM using binomial data
ggplot :Error in as.Date.numeric(value) : 'origin' must be supplied
How to display non-English (Japanese/Chinese) characters/text in Shiny on Windows? (NOT ABLE TO ENCODE)
Merge Two Dataframes
Help with Rcode! (University work)
RStudio Server on Redhat issue with ggplot2 axis charts wrong
Remove dubliertes
R not recognizing first data point
the data points on the graph are not plotted, even though the header of the csv file can be shown, i think somewhere in my code its not able to read the data
I used clean data according a column number range isn't work correct.
the data points on the graph are not plotted, even though the header of the csv file can be shown, i think somewhere in my code its not able to read the data
twitter analysis
R Studio crashing with dplyr joins?
need help for tweet scraping
Evaluation error: Operation not allowed without an active reactive context
Forecasting plot -adding fitting and validation area
Remove values Based on a criteria and re-run average, sd and sem
Compare each element in same column with other set of records
Downloading Data after Filteration
Automatic scale with ggplot
transforming coordinate system
How to include superscripts and subscripts on axis from hist3d plots? plot3D package
Matrix Multiplication
Limiting the range of colours in a featureplot
Pairwise alignment error message
New user- troubleloading my 3d data for analysis
Not understanding the reason for the error and solution to it
Error in missForest command
How to compute the value for factor variables?
R Shiny apps dashboard - making a PDF print
3x3 FActorial Design with Repeated Measures
RStudio 1.2 `NA` show up as 0 in dataframe viewing tab
table in markdown
Linear regression with data from excel
Bookdown not acknowledging (finding) css and tex definitions
Convert values in alternate rows of first n columns to negative
Not understanding the reason for the error and solution to it
Character addition in column rows
Calculating the averages in bins
group_by then mutate not working
Error in UseMethod("predictLink") when trying to fit Lee-Carter using StMoMo
Shiny debugging error with if sentence
why R did not recognise month of "January" in my plot
About creating multi variable bar chart using ggplot
Rstudio crashing when trying to run xgboost model
Reprex FAQs: should we say more about when NOT to use `reprex()`?
problem with time rstudio
PSnonmem and GGPLOT
New to R - need any help that I can get
Graphing time Series
ggsave very slow
gganimate has problem of white space in plot area
any r tutors available here? I need someone to look at my code
numericInput - hint implies only integer values valid
How to combine values within a variable
How to combine values within a variable
How to combine values within a variable
Create a command to compress the space in the description
Linear Mixed Model
Relevel function in R for GLM
confusion matrix - predict function
shiny plot based on window size
Missing interaction effect in 2-way anova result
How can i access list of list
LateX equations not porting with includeMarkdown
Problems with knitting to PDF
Need serious help - inherited an R script and I don't program or do this for a living
Common Error "all arguments must have the same length"
Stack Area Chart creating Holes/Gaps
Hadley on reproducible examples: add to reprex FAQ?
Willingness to pay by gender
Rstudio and Linux Ubuntu18.04
Willingness to pay by gender
analysis help--choosing method of analysis
Bug of the plot generated by R code
superimposed geom_* with ggplot2
Violin plot: binary data
How to substring value from row in r
str_replace applying to more than one column with mutate_at
recode characters to values (clueless warning)
Specifying plotting settings plot(ACF(data))
add a legend to a ggplot2 plot
Error message: 'names' attribute must be the same length as the vector
Assign range of dates for each unique row in the dataframe.
Forecasting data of export Wh-with irregularly spaced time series
Knit as pdf not work
Interactivity in ggvis
Edx course problem - creating new column, applying function
Edx course problem - creating new column, applying function
Error when trying to use corrplot
Help with: Error in seq.default(1, nchr, by = ncycle) : invalid '(to - from)/by'
R-Studio - Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels
R Studio Package Installation Not Recognized (SOLVED--THANKS)
[ solved ] RStudio IDE Viewer is not rendering the styled HTML output from ztable package
Date format conversion
RStudio - loop command for series of images and export without overwriting
Confidence Interval: getting "NA" as an answer. Why?
Problem with Variable?
invalid multibyte character
Smacof unfolding - package onboarding suggestions
failed to Biological Id Translator
Using list columns in data.table
how to save internal output in R studio?
What does nnet minimise
What does nnet minimise
Regarding glm.nb and the theta parametre.
Query related to R language to find percentage
Creating a time serie - help I am a beginner :) -
How to fit large amounts of data into Flexdashboard
How to replace x- axis values (log scale) with their respective untransformed linear values in base R histogram
Error in as.environment(pos) : invalid 'pos' argument
Restart Rstudio in order to have my code working
Making aggregated rate per 100 000
Extract time then save into a new dataframe
ggplot with reactive data input question
Help for graphical representation
Regarding Multiple Bar diagram
R Markdown is not knitting tables
Hybridizing "Basic DataTable" and Data Explorer in "SuperZip example"
OR operation on similar row items
OR operation on similar row items
How to plot categorical data in R?
R-Beginner: How to seperate to groups
Filter out empty elements from list col
google route optimizer
Saving factor scores from factor analysis
Develop web application using Gapminder(total population dataset)
You can help me! I have to Open a .RAR file
Janitor: remove_empty() or remove_empty_cols() not appearing
R presentation section headers look way fatter and more bold when viewed in browser vs. preview
Error in RMarkdown knit yaml
Problem with Linear mixed Model in Split-plot design
R Studio Mac axis not showing label
Knit to PDF only opens preview the first time
joining or merging two datasets
Error in creating recession bar with tis package
Help with a strange Error messsage
Change color text axis in barplot
Why am I getting the same output even if I use different input images?
How to subtract dates using dbplyr
Joining datasets using foverlaps
color the y axis variables with different colors
R crosstab with thousands delimiter
Creating server for Web applications
Barplot not in scale
Cannot get scatter plot right
what package do I have to download to get a Quantile-Quantile graph?
Student, looking for help with rStudio and the acs package.
Creating persistent data from within an R Markdown code chunk
Saving clean data into new data frame
Half year periods based on date
Cannot download plotly charts into png format or svg format.
Exporting tables to xls or ppt
Work with multiple .osm files [Open Street Map]
Is "create a reprex" becoming a bit too stackoverflow-esque?
Restructure data frame through aggregation
How to groupby values in R for the same value?
Two Regression Lines in single plot, shaded by year, and points indicating a different location
How to obtain individual slope coefficients for a growth curve model
how can I summarize survey answers from a data table in R shiny?
POSIXct Problem
Unable to run current chunk of code - RStudio
how to make a graph with a list class variable?
Ggplot label - advanced background
Bayes Decision Boundary
Savewidget to default browser location not working directory
Bayes Decision Boundary
Stacked bar chart with continuous Y variables
Help with Function()
Column that is a list
What is the difference of occurrence and density for different types with in 4 different populations
Cannnot Knit R Markdown
Correlation problems in Rstudio
time series modelling
How to plot several categorical variables in r
using sqldf to join two data frame but result is converting from Int to Logical
How to plot several categorical variables in r
im looking for two codes
How to run a mult. Linear regression in R, after importing the data.
How to extract factors names from anova function
Conversion csv into time series ts R Studio
pa package in R - performance attribution
Problem finding missingness (wrangling data) using tidyverse. Getting Evaluation error.
box plots are overlapping in ggplot2
Adding a Legend to an Existing ggplot
graph issues with overlapping boundary
Remove the axis.y.text
ggplot2 error message for Hidden Markov Models
ggplot : Beginner question about string data.
Have a warning or prompt before closing the Rmarkdown
Removing NA values from a specific column and row
PCA plot mean point
str_replace_all problem
How to change Pearson to Spearman rank correlation
Create a percentage stacked bar chart
Help on - Loop - argument is of length zero
Help on - Loop - argument is of length zero
RMarkdown knit fail when works in editor
Animation Slider Date Order
Why am I receiving a map_lgl error using dplyr for filtering my data?
2 graphs in one plot in shiny not showing lines on geom_line
data frame not available outside observe event
Point shape in ggplot2 with distance matrix
landsatlinkr version 0.5.0 is not creating t.c file hence error during compositing
deidentify and duplicate data
Code works fine with R Script, but does not run with knitr
Comparing Panel models after they have clustered SE R
Problems with inserting Data
Delete all rows with non-missing values in certain columns
Same code, same data, different output.
replacing NA with for loop vs dplyr
data.table error: Error in is.finite(if (is.character(from)) from <- as.numeric(from) else from) : default method not implemented for type 'closure'
NAs introduced by coercion
Visualizing interaction terms
Create Function
Going long to wide with multiple variables based on
Cannot see the complete plot for all values of variable
Code chunk wont stop executing
Getting monthly data into daily/weekly data
FactomineR - MFA error
Cannot plot plot a tobit model--getting error message(what do I do)?
Plot multiple line graph over time
Prediction from knn model
I want to create a matrix with rows and columns
ggplot with conditions
Filter-function help please
Compare each record value from two different data sets
How to check Outlier after imputing the missing value by Hmisc Package
Wordcloud and plotting sentiment score error
Turning non-military time to military time
Filter bigram list from a dataframe
geom_ribbon working well in time series data
Non linear equation how add confidence intervals
Calculate Anomaly in Temperature
Set.seed() with simulations
Seeking help for using filter and mutate command to break down a current variable into separate variables
Rstudio crashs on macOS with the X11 cairo type window
Principal Components Analysis (PCA)
Error: Long vectors not supported yet
Understanding window sizes when using kNN
Problem with changing the language in Rstudio
Dplyr filter from another dataframe
Using a Variable Where Quotes Are Needed in Function Argument
split this topic #2

A post was split to a new topic: Best Practices: how to prepare your own data for use in a reprex if you can’t, or don’t know how to reproduce a problem with a built-in dataset?


#3

Thanks, Miles, this is great!

A few more resources to add:


Not reprex-specific, but helpful for asking R-related questions


Community Sustainer (Moderator) Guide
Reprex vs. reprex-package discussions
Reprex vs. reprex-package discussions
split this topic #6

17 posts were split to a new topic: Reprex vs. reprex-package discussions


Box plots aren't displaying correctly
#7

For sharing simple data.frames (those containing only basic types, no dates, no factors, and no row names) I suggest using wrapr::draw_frame() to build sharable examples.

For example suppose our example was the following data.

d <- head(ggplot2::diamonds) 

wrapr::draw_frame can share this data in a very legible form:

library("wrapr")
cat(draw_frame(d))

This outputs the following (older versions of wrapr do not add the "::" qualifier).

wrapr::build_frame(
   "carat", "cut"      , "color", "clarity", "depth", "table", "price", "x" , "y" , "z"  |
   0.23   , "Ideal"    , "E"    , "SI2"    , 61.5   , 55     , 326L   , 3.95, 3.98, 2.43 |
   0.21   , "Premium"  , "E"    , "SI1"    , 59.8   , 61     , 326L   , 3.89, 3.84, 2.31 |
   0.23   , "Good"     , "E"    , "VS1"    , 56.9   , 65     , 327L   , 4.05, 4.07, 2.31 |
   0.29   , "Premium"  , "I"    , "VS2"    , 62.4   , 58     , 334L   , 4.2 , 4.23, 2.63 |
   0.31   , "Good"     , "J"    , "SI2"    , 63.3   , 58     , 335L   , 4.34, 4.35, 2.75 |
   0.24   , "Very Good", "J"    , "VVS2"   , 62.8   , 57     , 336L   , 3.94, 3.96, 2.48 )

The point is, with the wrapr package loaded the above output is actually executable code that produces the same data.frame. One can then copy and paste the above code to start a fresh example from this data (and not need to include steps that took one to this point).

(Was asked to post this to this thread here.)


Error: cannot allocate vector of size 12.4 Gb
#8

It is now out (and yes, it is great!)


Support links to explain two specific steps involved in building a reproducible example
Reprex vs. reprex-package discussions