ipmisc (version 1.2.0)

outlier_df: Adding a column to dataframe describing outlier status

Description

Adding a column to dataframe describing outlier status

Usage

outlier_df(data, x, y, outlier.label, outlier.coef = 1.5, ...)

Arguments

data

A dataframe (or a tibble) from which variables specified are to be taken. A matrix or tables will not be accepted.

x

The grouping variable from the dataframe data.

y

The response (a.k.a. outcome or dependent) variable from the dataframe data.

outlier.label

Label to put on the outliers that have been tagged. This can't be the same as x argument.

outlier.coef

Coefficient for outlier detection using Tukey's method. With Tukey's method, outliers are below (1st Quartile) or above (3rd Quartile) coef times the Inter-Quartile Range (IQR) (Default: 1.5).

...

Additional arguments.

Value

The dataframe entered as data argument is returned with two additional columns: isanoutlier and outlier denoting which observation are outliers and their corresponding labels.

Examples

Run this code
# NOT RUN {
# adding column for outlier and a label for that outlier
outlier_df(
  data = morley,
  x = Expt,
  y = Speed,
  outlier.label = Run,
  outlier.coef = 2
) %>%
  dplyr::arrange(outlier)
# }

Run the code above in your browser using DataLab