📄 varused.r
字号:
varUsed <- function(x, by.tree=FALSE, count=TRUE) { if (!inherits(x, "randomForest")) stop(deparse(substitute(x)), "is not a randomForest object") if (is.null(x$forest)) stop(deparse(substitute(x)), "does not contain forest") p <- length(x$forest$ncat) # Total number of variables. if (count) { if (by.tree) { v <- apply(x$forest$bestvar, 2, function(x) { xx <- numeric(p) y <- table(x[x>0]) xx[as.numeric(names(y))] <- y xx }) } else { v <- numeric(p) vv <- table(x$forest$bestvar[x$forest$bestvar > 0]) v[as.numeric(names(vv))] <- vv } } else { v <- apply(x$forest$bestvar, 2, function(x) sort(unique(x[x>0]))) if(!by.tree) v <- sort(unique(unlist(v))) } v}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -