Emulate lm.
myFun <-
function(formula, data, na.action, id, ...){
mf <- match.call(expand.dots = FALSE)
m <- match(c("formula", "data", "id", "na.action"), names(mf), 0L)
mf <- mf[c(1L, m)]
mf$drop.unused.levels <- TRUE
mf[[1L]] <- as.name("model.frame")
mf
Suppose I have the following function
myFun <- function(formula, data){
f <- formula(formula)
dat <- model.frame(f, data)
dat
}
Applying it with this sample data yields a new dataframe:
qqq <- data.frame(grade = c(3, NA, 3,4,5,5,4,3), score = rnorm(8), idVar =
c(
2 matches
Mail list logo