shrink: Remove some percentage or number of observations.

Description Usage Arguments Value Examples

View source: R/Helpers.R

Description

Often it is desirable to remove a certain number or percentage of a vector. This function will accept either an input number size or percentage to be removed. These can be removed from either the start or end of the vector, or the vector can be sorted first and then the items can be removed from the start or end.

Usage

1
2
shrink(x, proportion = NULL, size = NULL, side = "top",
  na.rm = TRUE)

Arguments

x

A vector of numeric values

proportion

The proportion of values to be removed. For example, if we wanted to remove 15 percent, the proportion entered would be 0.15.

size

The number of observations to be removed.

side

Where should the values be removed from. start and end remove the observations from the start and end of the vector, while top and bottom will cause the vector to first be sorted and then remove either the largest or smallest observations.

Value

A vector that is shorter than the input.

Examples

1
2
3
4
5
6
7
set.seed(8675309)
input <- rpois(10, lambda=4)
input
shrink( input, proportion=0.1, side='start')
shrink( input, proportion=0.1, side='end')
shrink( input, proportion=0.1, side='top')
shrink( input, proportion=0.1, side='bottom')

dereksonderegger/PepSeq documentation built on July 24, 2019, 12:57 a.m.