Questions tagged [reprex]

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.

24 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
  • 63
  • 5
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,389
  • 6
  • 22
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
  • 21,789
  • 5
  • 13
  • 47
2
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
  • 495
  • 6
  • 16
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
  • 50,277
  • 118
  • 274
  • 437
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
  • 447
  • 2
  • 14
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
  • 77
  • 9
1
vote
1 answer

How to run reprex in Rstudio? I encountered an error

after installation the package, > library(reprex) > (y <- 1:4) [1] 1 2 3 4 > mean(y) [1] 2.5 > reprex() Rendering reprex... Error: callr subprocess failed: :18:7: unexpected 'in' 17: #+ reprex-body 18: Error in ^
user253546
  • 37
  • 6
1
vote
1 answer

reprex ignores output of system()

Consider the following cross-platform test: > system('echo hello') hello If in RStudio I copy the string system('echo hello') and the run reprex::reprex() the output is not captured: Is there any way to capture the output? I'm on macOS.
geotheory
  • 19,464
  • 21
  • 95
  • 172
1
vote
1 answer

Test condition of two columns on groups

I'm trying to make a new column that checks on a group (id and number) if two columns have the same observations (classification and classification-1"). This is the original data frame: reprex <- tribble(~"id", ~"number", ~"year", …
Paula
  • 303
  • 1
  • 7
1
vote
1 answer

Flexdashboard opens new tab with every user input

I would like to ask for help with a Flexdashboard using Plotly and Shiny. The only thing now is that the app is throwing away browser tabs like there's no tomorrow. For every reactive input from the user, the app opens a new tab, where it does…
Pablo Bernabeu
  • 344
  • 2
  • 16
1
vote
1 answer

reprex in Rstudio

I an unable to get reprex to run. Here is a copy of the console session: > library(reprex) > y <- 1:4 > mean(y) [1] 2.5 > reprex() Error in file(con, "w") : cannot open the connection In addition: Warning message: In file(con, "w") : cannot open…
1
vote
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
  • 3,588
  • 1
  • 11
  • 35
1
vote
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
  • 6,808
  • 4
  • 32
  • 55
1
2