Skip to content

Instantly share code, notes, and snippets.

@djnavarro
Created March 25, 2019 09:45
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 djnavarro/e93b3db1401d5589fe61be1f78e25262 to your computer and use it in GitHub Desktop.
Save djnavarro/e93b3db1401d5589fe61be1f78e25262 to your computer and use it in GitHub Desktop.
Probably the most malicious thing I've done with R
# operator that reverses the direction of assignment
# only if called from the global environment
`%>>%` <- function(x,y) {
if(sys.nframe() == 1) {
assign(deparse(substitute(y)), x, parent.frame())
} else {
assign(deparse(substitute(x)), y, parent.frame())
}
}
# redefine the assigment operator and cover our
# tracks just to make it as nasty as possible
unlockBinding("<-", baseenv())
`<-` <<- `%>>%`
rm(`%>>%`)
lockBinding("<-", baseenv())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment