File: regtest-node.R

package info (click to toggle)
r-cran-partykit 1.2-23-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,832 kB
  • sloc: ansic: 91; sh: 75; makefile: 38
file content (18 lines) | stat: -rw-r--r-- 554 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
suppressWarnings(RNGversion("3.5.2"))

library("partykit")
set.seed(1)

mysplit <- function(x) partysplit(1L, breaks = as.double(x))
x <- vector(mode = "list", length = 5)
x[[1]] <- list(id = 1L, split = mysplit(1 / 3), kids = 2:3, info = "one")
x[[2]] <- list(id = 2L, info = "two")
x[[3]] <- list(id = 3L, split = mysplit(2 / 3), kids = 4:5, info = "three")
x[[4]] <- list(id = 4L, info = "four")
x[[5]] <- list(id = 5L, info = "five")

rx <- as.partynode(x)
stopifnot(identical(as.list(rx), x))

dat <- data.frame(x = runif(100))
kidids_node(rx, dat)