Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

trimSum

Trim a vector such that the last/first value represents the sum of trimmed values


Description

trimSum trims (shortens) a vector in such a way that the last or first value represents the sum of trimmed values. User needs to specify the desired length of a trimmed vector.

Usage

trimSum(x, n, right=TRUE, na.rm=FALSE, ...)

Arguments

x

numeric, a vector of numeric values

n

numeric, desired length of the output

right

logical, trim on the right/bottom or the left/top side

na.rm

logical, remove NA values when applying a function

...

arguments passed to other methods - currently not used

Value

Trimmed vector with a last/first value representing the sum of trimmed values

Author(s)

Gregor Gorjanc

See Also

Examples

x <- 1:10
trimSum(x, n=5)
trimSum(x, n=5, right=FALSE)

x[9] <- NA
trimSum(x, n=5)
trimSum(x, n=5, na.rm=TRUE)

gdata

Various R Programming Tools for Data Manipulation

v2.18.0
GPL-2
Authors
Gregory R. Warnes, Ben Bolker, Gregor Gorjanc, Gabor Grothendieck, Ales Korosec, Thomas Lumley, Don MacQueen, Arni Magnusson, Jim Rogers, and others
Initial release
2017-06-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.