我为我公司的一群用户管理一个R编程环境。我们经常处理敏感数据,我的一些数据科学家已经开始在R中使用reprex包。
这是一个很棒的小包,但我注意到当你调用它时,默认情况下这个包会将图片上传到imgur。如果我们的用户不小心上传了一些敏感的东西,这对我们来说是有问题的。
有没有办法在Rprofile.site中或通过RStudio中的某些设置为所有用户更改此默认值?
发布于 2020-04-26 16:34:10
默认情况下,reprex通过在knitr中设置upload.fun()来将图像上传到imgur。
如reprex手册页所示
reprex还设置了的upload.fun。它缺省为knitr::imgur_upload(),因此reprex生成的图形可以正确地显示在GitHub、Stack Overflow或to上。请注意,此函数需要包httr & xml2或RCurl & XML,具体取决于您的knitr版本。当venue = "r“时,upload.fun被设置为identity,以便数字保持本地。在这种情况下,您可能还需要设置outfile。您可以在代码中使用特殊注释来补充或覆盖这些选项(请参见示例)。
示例:
# 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")希望对你有所帮助。
https://stackoverflow.com/questions/61412158
复制相似问题