Created
March 25, 2019 09:45
-
-
Save djnavarro/e93b3db1401d5589fe61be1f78e25262 to your computer and use it in GitHub Desktop.
Probably the most malicious thing I've done with R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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