MASS: Interfaces for MASS package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10

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
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
## Not run: 
library(intubate)
library(magrittr)
library(MASS)

## corresp
## Original function to interface
corresp(~ Age + Eth, data = quine)

## The interface reverses the order of data and formula
ntbt_corresp(data = quine, ~ Age + Eth)

## so it can be used easily in a pipeline.
quine %>%
  ntbt_corresp(~ Age + Eth)
  
## glm.nb
## Original function to interface
glm.nb(Days ~ Sex/(Age + Eth*Lrn), data = quine)

## The interface reverses the order of data and formula
ntbt_glm.nb(data = quine, Days ~ Sex/(Age + Eth*Lrn))

## so it can be used easily in a pipeline.
quine %>%
  ntbt_glm.nb(Days ~ Sex/(Age + Eth*Lrn))

## lda
Iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]),
                   Sp = rep(c("s","c","v"), rep(50,3)))

## Original function to interface
lda(Sp ~ ., Iris)

## The interface reverses the order of data and formula
ntbt_lda(Iris, Sp ~ .)

## so it can be used easily in a pipeline.
Iris %>%
  ntbt_lda(Sp ~ .)

stackloss %>%
  ntbt_lda(stack.loss ~ .) %>%
  summary()

## lm.gls
## Original function to interface
lm.gls(conc ~ uptake, CO2, W = diag(nrow(CO2)))

## The interface reverses the order of data and formula
ntbt_lm.gls(CO2, conc ~ uptake, W = diag(nrow(CO2)))

## so it can be used easily in a pipeline.
CO2 %>%
  ntbt_lm.gls(conc ~ uptake, W = diag(nrow(CO2)))

## lm.ridge
## Original function to interface
lm.ridge(GNP.deflator ~ ., longley)

## The interface reverses the order of data and formula
ntbt_lm.ridge(longley, GNP.deflator ~ .)

## so it can be used easily in a pipeline.
longley %>%
  ntbt_lm.ridge(GNP.deflator ~ .)

## loglm
## Original function to interface
xtCars93 <- xtabs(~ Type + Origin, Cars93)
loglm(~ Type + Origin, xtCars93)

## The interface reverses the order of data and formula
xtCars93 <- ntbt_xtabs(Cars93, ~ Type + Origin)
ntbt_loglm(xtCars93, ~ Type + Origin)

## so it can be used easily in a pipeline.
Cars93 %>%
  ntbt_xtabs(~ Type + Origin) %>%
  ntbt_loglm(~ Type + Origin)

## logtrans
## Original function to interface
logtrans(Days ~ Age*Sex*Eth*Lrn, data = quine,
         alpha = seq(0.75, 6.5, len=20))

## The interface reverses the order of data and formula
ntbt_logtrans(data = quine, Days ~ Age*Sex*Eth*Lrn,
              alpha = seq(0.75, 6.5, len=20))

## so it can be used easily in a pipeline.
quine %>%
  ntbt_logtrans(Days ~ Age*Sex*Eth*Lrn,
                alpha = seq(0.75, 6.5, len=20))

## polr
op <- options(contrasts = c("contr.treatment", "contr.poly"))

## Original function to interface
polr(Sat ~ Infl + Type + Cont, housing)

## The interface reverses the order of data and formula
ntbt_polr(housing, Sat ~ Infl + Type + Cont)

## so it can be used easily in a pipeline.
housing %>%
  ntbt_polr(Sat ~ Infl + Type + Cont)

options(op)

## qda
set.seed(123) ## make reproducible
tr <- sample(1:50, 25)

iris3df <- data.frame(cl = factor(c(rep("s",25), rep("c",25), rep("v",25))),
                      train = rbind(iris3[tr,,1], iris3[tr,,2], iris3[tr,,3]))

## Original function to interface
qda(cl ~ ., iris3df)

## The interface reverses the order of data and formula
ntbt_qda(iris3df, cl ~ .)

## so it can be used easily in a pipeline.
iris3df %>%
  ntbt_qda(cl ~ .)

## rlm
## Original function to interface
rlm(stack.loss ~ ., stackloss)

## The interface reverses the order of data and formula
ntbt_rlm(stackloss, stack.loss ~ .)

## so it can be used easily in a pipeline.
stackloss %>%
  ntbt_rlm(stack.loss ~ .) %>%
  summary()
  
stackloss %>%
  ntbt_rlm(stack.loss ~ ., psi = psi.hampel, init = "lts") %>%
  summary()

stackloss %>%
  ntbt_rlm(stack.loss ~ ., psi = psi.bisquare) %>%
  summary()

## End(Not run)

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