Last active
January 19, 2019 12:36
-
-
Save flodel/5283216 to your computer and use it in GitHub Desktop.
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
ok.comma <- function(FUN) { | |
function(...) { | |
arg.list <- as.list(sys.call())[-1L] | |
len <- length(arg.list) | |
if (len > 1L) { | |
last <- arg.list[[len]] | |
if (missing(last)) { | |
arg.list <- arg.list[-len] | |
} | |
} | |
do.call(FUN, arg.list) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If one creates ones own function and uses
ok.comma
as it is defined to replace a function definition, egf <- ok.comma(f)
, then it leads to an infinite loop. Furthermore if you call anok.comma
-d function under your definition, variables will always be read from.GlobalEnv
. This is clearly undesirable. Two slight modifications resolves this issue:In my GitHub package
devtools::install_github('RLogik/rbettersyntax', dep=TRUE);
I provide this modification along with a few other methods. Credit is given to you for this method.