Learn R Programming

eeptools (version 0.9.1)

thresh: A function to return the maximum percentage of the cumulative sum represented by a subset of the vector

Description

Returns the proportion of the cumulative sum represented by the number of elements in the vector a user specifies. This allows the user to identify the maximum proportion of the total that only X number of elements may represent in the vector.

Usage

thresh(x, cutoff, na.rm = TRUE)

Arguments

x
a numeric vector, missing values are allowed
cutoff
numeric, the number of elements to look at
na.rm
logical, should missing values be excluded?

Value

A numeric proportion

Details

Calculates the proportion of a numeric vector reached after sorting the vector in ascending order and stopping at the specified count

See Also

cutoff which this function is related to

Examples

Run this code
# for vector
a <- rnorm(100, mean=6, sd=1)
thresh(a, 8) #return minimum number of elements to account 70 percent of total

Run the code above in your browser using DataLab