Description Usage Arguments Details Value Methods (by class) Author(s)
View source: R/fun-clip_data.R
Remove the smallest and greatest values from a vector of from a column of a data frame.
1 2 3 4 5 6 7 8 9 10 11 12 13 | clip_data(x, clip = 1L, ...)
## Default S3 method:
clip_data(x, clip = 1L, preserve.order = TRUE, ...)
## S3 method for class 'factor'
clip_data(x, clip = 1L, preserve.order = TRUE, ...)
## S3 method for class 'numeric'
clip_data(x, clip = 1L, preserve.order = TRUE, ...)
## S3 method for class 'data.frame'
clip_data(x, clip = 1L, column, ...)
|
x |
a vector or a data frame |
clip |
either number(s) or fraction(s) (rounding up)
of values to be removed, see |
... |
arguments passed to other methods |
preserve.order |
logical flag whether result should be returned sorted or in the original order (default) |
column |
for |
The clip
arguments determines the number of items/observations removed:
if clip >= 1, this number of observations will be removed
if clip < 1, this fraction of observations will be removed
if clip < 1 and of length 1, half the fraction will be removed from the bottom and half from the top of the range
if clip >= 1 and of length 1, that number of items will be removed from both bottom and top of the range
if clip is of length 2, the first value determines clipping at the bottom of the range and the second - at the top
After clipping a t test is run to determine whether the clipping significantly changed the mean of the vector. In case of a data frame this is also done for every other numeric variable. The result of the test is reported as a warning if positive (p < 0.05) and as a message if negative.
A clipped vector or data frame.
default
: default method
factor
: coerces x
to characer, calls the character method, and restores the original levels
numeric
: adds a location check
data.frame
: clips the specified column and test all numeric columns for changes
Aleksander Chlebowski, June 2018
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.