1

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 uploads images to imgur when you call it. This would be problematic for us if one of our users accidentally uploaded something sensitive.

Would there be a way to change this default for all users perhaps in a Rprofile.site or via some setting in RStudio?

drizzle123
  • 517
  • 5
  • 18

1 Answers1

1

By default, reprex upload the image to imgur by setting upload.fun() in knitr.

As shown in the man page of reprex

reprex also sets knitr's upload.fun. It defaults to knitr::imgur_upload() so figures produced by the reprex appear properly on GitHub, Stack Overflow, or Discourse. Note that this function requires the packages httr & xml2 or RCurl & XML, depending on your knitr version. When venue = "r", upload.fun is set to identity, so that figures remain local. In that case, you may also want to set outfile. You can supplement or override these options with special comments in your code (see examples).

The example:

# write reprex to file AND keep figure local too, i.e. don't post to imgur
tmp <- file.path(tempdir(), "foofy")
reprex({
  #+ setup, include = FALSE
  knitr::opts_knit$set(upload.fun = identity)

  #+ actual-reprex-code
  #' Some prose
  ## regular comment
  (x <- 1:4)
  median(x)
  plot(x)
  }, outfile = tmp)
list.files(dirname(tmp), pattern = "foofy")

Hopes helpful for you.

yang
  • 719
  • 3
  • 11
  • Thanks for sharing. I did see this in the documentation. It's unclear to me though how this could be set up as the default for all the users I'm managing. – drizzle123 Apr 27 '20 at 17:45
  • Maybe set the argument `venue = "r"` in `reprex()` will solve the problem, try set `venue = "r"` as default by adding `reprex <- purrr::partial(reprex::reprex, venue = "r")` to your `~/.Rprofile` – yang Apr 28 '20 at 00:51
  • Ahh interesting. Somebody gave similar advice in this RStudio community thread: https://community.rstudio.com/t/how-to-overwrite-reprex-uploading-to-imgur/63164. It isn't perfect though since the reprex button in RStudio won't respect this change in the Rrofile.site. Additionally if the user does reprex::reprex() it won't respect the change either. – drizzle123 Apr 29 '20 at 17:28