R Step function looks for data in global environment, not inside defined function
问题 I have a problem with step forward regression and My understanding is that i don't pass argument Data correctly. I have the function: ForwardStep <- function(df,yName, Xs, XsMin) { Data <- df[, c(yName,Xs)] fit <- glm(formula = paste(yName, " ~ ", paste0(XsMin, collapse = " + ")), data = Data, family = binomial(link = "logit") ) ScopeFormula <- list(lower = paste(yName, " ~ ", paste0(XsMin, collapse = " + ")), upper = paste(yName, " ~ ", paste0(Xs, collapse = " + "))) result <- step(fit,