⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 randomforest.formula.r

📁 是基于linux系统的C++程序
💻 R
字号:
"randomForest.formula" <-    function(formula, data = NULL, ..., subset, na.action = na.fail) {### formula interface for randomForest.### code gratefully stolen from svm.formula (package e1071).###    if (!inherits(formula, "formula"))        stop("method is only for formula objects")    m <- match.call(expand = FALSE)    ## Catch xtest and ytest in arguments.    if (any(c("xtest", "ytest") %in% names(m)))        stop("xtest/ytest not supported through the formula interface")    names(m)[2] <- "formula"    if (is.matrix(eval(m$data, parent.frame())))        m$data <- as.data.frame(data)    m$... <- NULL    m$na.action <- na.action    m[[1]] <- as.name("model.frame")    m <- eval(m, parent.frame())    y <- model.response(m)    Terms <- attr(m, "terms")    attr(Terms, "intercept") <- 0    ## Drop any "negative" terms in the formula.    ## test with:    ## randomForest(Fertility~.-Catholic+I(Catholic<50),data=swiss,mtry=2)    m <- model.frame(terms(reformulate(attributes(Terms)$term.labels)),                     data.frame(m))    ## if (!is.null(y)) m <- m[, -1, drop=FALSE]    for (i in seq(along=ncol(m))) {        if (is.ordered(m[[i]])) m[[i]] <- as.numeric(m[[i]])    }    ret <- randomForest(m, y, ...)    cl <- match.call()    cl[[1]] <- as.name("randomForest")    ret$call <- cl    ret$terms <- Terms    if (!is.null(attr(m, "na.action")))        ret$na.action <- attr(m, "na.action")    class(ret) <- c("randomForest.formula", "randomForest")    return(ret)}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -