Created
December 26, 2013 21:15
-
-
Save multidis/8138757 to your computer and use it in GitHub Desktop.
Match formula, data call in R function and create corresponding dataframe. Typical beginning of new functions utilizing formula interface.
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
someFun <- function(formula, data, ...) { | |
mc <- match.call() | |
m <- match(c("formula","data"), names(mc), 0L) | |
mf <- mc[c(1L, m)] | |
mf[[1L]] <- as.name("model.frame") | |
mf <- eval(mf, parent.frame()) | |
data.st <- data.frame(mf) | |
return(data.st) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment