Learn R Programming

cmstatr (version 0.9.3)

augment.mnr: Augment data with information from an mnr object

Description

Augment accepts an mnr object (returned from the function maximum_normed_residual()) and a dataset and adds the column .outlier to the dataset. The column .outlier is a logical vector indicating whether each observation is an outlier.

When passing data into augment using the data argument, the data must be exactly the data that was passed to maximum_normed_residual.

Usage

# S3 method for mnr
augment(x, data = x$data, ...)

Value

When data is supplied, augment returns data, but with one column appended. When data is not supplied, augment

returns a new tibble::tibble() with the column values containing the original values used by maximum_normed_residaul plus one additional column. The additional column is:

  • .outler a logical value indicating whether the observation is an outlier

Arguments

x

an mnr object created by maximum_normed_residual()

data

a data.frame or tibble::tibble() containing the original data that was passed to maximum_normed_residual

...

Additional arguments. Not used. Included only to match generic signature.

See Also

maximum_normed_residual()

Examples

Run this code
data <- data.frame(strength = c(80, 98, 96, 97, 98, 120))
m <- maximum_normed_residual(data, strength)

# augment can be called with the original data
augment(m, data)

##   strength .outlier
## 1       80    FALSE
## 2       98    FALSE
## 3       96    FALSE
## 4       97    FALSE
## 5       98    FALSE
## 6      120    FALSE

# or augment can be called without the orignal data and it will be
# reconstructed
augment(m)

## # A tibble: 6 x 2
##   values .outlier
##     
## 1     80 FALSE
## 2     98 FALSE
## 3     96 FALSE
## 4     97 FALSE
## 5     98 FALSE
## 6    120 FALSE

Run the code above in your browser using DataLab