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 36 37 38 39 40 41 42 43 44 45
|
R version 3.5.0 (2018-04-23) -- "Joy in Playing"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> suppressWarnings(RNGversion("3.5.2"))
>
> library("partykit")
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm
> 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)
[1] 1 2 2 2 1 2 2 2 2 1 1 1 2 2 2 2 2 2 2 2 2 1 2 1 1 2 1 2 2 2 2 2 2 1 2 2 2
[38] 1 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 1 1 1 2 2 2 2 1 2 1 2 1 2 2 1 2 2 2 2 2
[75] 2 2 2 2 2 2 2 2 2 1 2 1 2 1 1 1 1 1 2 2 2 2 2 2 2 2
>
> proc.time()
user system elapsed
1.643 0.115 1.727
|