1 | ptree_criteria(newtree, node_id, left)
|
newtree |
|
node_id |
|
left |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (newtree, node_id, left)
{
if (nodes(newtree, node_id)[[1]]$terminal) {
return("(error: terminal node)")
}
if (nodes(newtree, node_id)[[1]]$psplit$ordered) {
sp <- nodes(newtree, node_id)[[1]]$psplit$splitpoint
vn <- nodes(newtree, node_id)[[1]]$psplit$variableName
if (left) {
op <- "<="
}
else {
op <- ">"
}
return(paste(vn, op, sp))
}
else {
psplit <- nodes(newtree, node_id)[[1]]$psplit
if (left) {
l <- as.logical(psplit$splitpoint)
}
else {
l <- as.logical(!psplit$splitpoint)
}
r <- paste(attr(psplit$splitpoint, "levels")[l], sep = "",
collapse = "','")
return(paste(psplit$variableName, " in ('", r, "')",
sep = ""))
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.