How to overwrite reprex uploading to imgur for all users

69 Views Asked by At

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?

1

There are 1 best solutions below

3
On

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.