An R package to generate render small snippets of code to target formats that include both code and output that can be shared on code-oriented websites.
Questions tagged [reprex]
34 questions
4
votes
1 answer
Shiny observeEvent shows first event, but not second, third
TL;DR: observeEvent is only working on the first instance, but not subsequent.
Explanation:
In a small shiny app below, I dynamically build a URL based on user input, which points to the corresponding pre-rendered "timer" gif images I have hosted on…

Hirschey
- 95
- 5
3
votes
3 answers
Running reprexpy on PyCharm CE: ImportError: cannot import name 'contextfilter' from 'jinja2'
I installed reprexpy 0.3.1 on PyCharm CE but when I run it, I get the following error:
(...)
File "/Users/serena/PycharmProjects/pythonProject2/venv/lib/python3.7/site-packages/nbconvert/exporters/html.py", line 14, in
from jinja2…

Emy
- 817
- 1
- 8
- 25
3
votes
0 answers
R package to extract minimal code required to reproduce a result
A trivial example. Let's say this is the original code:
x = 1
y = 2
z = x * 3
If we specify that we want to reproduce z, then the package would return a new script containing only the lines of code required to generate the value z.
x = 1
z = x *…

D Greenwood
- 415
- 2
- 11
3
votes
1 answer
manual colors in ggplot using a function
I have a theme function and I would like to add scale_fill_manual(values=x) inside the function and update all of my plots but it does not work if I add this line inside my_theme function. Also I don't know how to supress the messages from loading…

xhr489
- 1,957
- 13
- 39
3
votes
1 answer
R reprex not rendering correct ggplot output for very tall plots
When creating very tall horizontal bar plots with ggplot2, the plot rendered when using the package reprex cuts off some of the data, while the axis labels remain in the correct positions. This is not the same behavior as the ggplot output for the…

DanTan
- 660
- 7
- 17
3
votes
1 answer
creating reproducible example using reprex package in r where a local file is being read
I often use reprex::reprex to create reproducible examples of R code to get help from others to get rid of errors in my code. Usually, I create minimal examples using datasets like iris or mtcars and it works well.
But I always fail to use reprex…

Indrajeet Patil
- 4,673
- 2
- 20
- 51
3
votes
1 answer
reprex setting output width
How do I set the width of a reprex output?
Say I have a code like this:
(x <- 1:100)
I get this with reprex::reprex(venue = "so")
(x <- 1:100)
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#> [18] 18 19 20 21 22…

David
- 9,216
- 4
- 45
- 78
2
votes
2 answers
Properly using reprex package when generating examples that load libraries
I would like to use a reprex package when generating an answer/question1 that utilises multiple packages. Say I want to provide the following answer
library("gdata")
dfA <- data.frame(colA = c(1, 2), colB = c(3, 4))
ls()
mv(from = "dfA", to =…

Konrad
- 17,740
- 16
- 106
- 167
2
votes
1 answer
Is there a way in R leaflet to assign different icons to certain locations?
I'm working on a shiny app for a local school district that will display a flag for schools that shouldn't have recess based on air pollutant conditions. The app will filter for one specific day and I've added a column called recess that, based on…

Keith
- 23
- 2
2
votes
2 answers
How to transform a dataframe console output to its structure automatically
Unexperienced users of StackOverflow tend to provide console output of the data they use:
id name
1 1 john
2 2 mary
Users with more experience should encourage them to provide a Reproducible Example, or to use dput to provide data structure,…

Waldi
- 39,242
- 6
- 30
- 78
2
votes
1 answer
Why reprex cannot render %>% results
I have no problem making this tibble:
library(dplyr)
library(tibble)
as.tibble(mtcars[2:3,2:3]) %>% mutate(cyl_x_disp = cyl * disp)
Which produce this:
# A tibble: 2 × 3
cyl disp cyl_x_disp
1 6 160 960
2 …

neversaint
- 60,904
- 137
- 310
- 477
1
vote
0 answers
R: Running code with reprex() produces expected output but running it from RStudio console produces error
When I select and copy all of the below code and then call reprex::reprex(), it successfully produces two plots. However, when I run the code by selecting all of the code and then pressing Cntrl + Enter from RStudio, it only produces the first plot…

socialscientist
- 3,759
- 5
- 23
- 58
1
vote
0 answers
Visualizing with ggplot yields different output using reprex vs. without reprex
I'm trying to add a segment in ggplot. However, adding alpha causes the segment to disappear. Although this is a known behavior that has been documented in many SO posts, I'm experiencing a particularly strange thing: when I generate the plot with…

Emman
- 3,695
- 2
- 20
- 44
1
vote
1 answer
How to overwrite reprex uploading to imgur for all users
I manage a R programming environment for a group of users at my company. We often work with sensitive data, and some of my data scientists have started using the reprex package in R.
It's a great little package, but I noticed the package by default…

drizzle123
- 517
- 5
- 18
1
vote
1 answer
Why does the code work when run as a R script but shows error when run in reprex?
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy))
#> Error in ggplot(data = mpg): could not find function "ggplot"
ggplot(mpg, aes(x=displ,y=hwy))+geom_point()
#> Error in ggplot(mpg, aes(x = displ, y = hwy)): could not find…

Chris
- 87
- 10