rpart: Interfaces for rpart package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

Interfaces to rpart functions that can be used in a pipeline implemented by magrittr.

Usage

1

Arguments

data

data frame, tibble, list, ...

...

Other arguments passed to the corresponding interfaced function.

Details

Interfaces call their corresponding interfaced function.

Value

Object returned by interfaced function.

Author(s)

Roberto Bertolusso

Examples

 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
## Not run: 
library(intubate)
library(magrittr)
library(rpart)

## rpart
## Original function to interface
fit <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis)
fit2 <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis,
              parms = list(prior = c(.65,.35), split = "information"))
par(mfrow = c(1,2), xpd = NA) # otherwise on some devices the text is clipped
plot(fit)
text(fit, use.n = TRUE)
plot(fit2)
text(fit2, use.n = TRUE)

## The interface reverses the order of data and formula
fit <- ntbt_rpart(data = kyphosis, Kyphosis ~ Age + Number + Start)
fit2 <- ntbt_rpart(data = kyphosis, Kyphosis ~ Age + Number + Start,
                   parms = list(prior = c(.65,.35), split = "information"))

par(mfrow = c(1,2), xpd = NA) # otherwise on some devices the text is clipped
plot(fit)
text(fit, use.n = TRUE)
plot(fit2)
text(fit2, use.n = TRUE)

## so it can be used easily in a pipeline.
par(mfrow = c(1,2), xpd = NA) # otherwise on some devices the text is clipped
kyphosis %>%
  ntbt_rpart(Kyphosis ~ Age + Number + Start) %T>%
  plot() %>%
  text(use.n = TRUE)
kyphosis %>%
  ntbt_rpart(Kyphosis ~ Age + Number + Start,
             parms = list(prior = c(.65,.35), split = "information")) %T>%
  plot() %>%
  text(use.n = TRUE)

## End(Not run)

rbertolusso/intubate documentation built on May 27, 2019, 3 a.m.