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

perc

Computes the percentage of values in a vector less than or greater than (and equal to) some value.


Description

Computes the percentage of values in a vector less than or greater than (and equal to) a user-supplied value.

Usage

perc(
  x,
  val,
  dir = c("geq", "gt", "leq", "lt"),
  na.rm = TRUE,
  digits = getOption("digits")
)

Arguments

x

A numeric vector.

val

A single numeric value.

dir

A string that indicates whether the percentage is for values in x that are “greater than and equal” "geq", “greater than” "gt", “less than and equal” "leq", “less than” "lt" the value in val.

na.rm

A logical that indicates whether NA values should be removed (DEFAULT) from x or not.

digits

A single numeric that indicates the number of decimals the percentage should be rounded to.

Details

This function is most useful when used with an apply-type of function.

Value

A single numeric that is the percentage of values in x that meet the criterion in dir relative to val.

Author(s)

Derek H. Ogle, derek@derekogle.com

Examples

## vector of values
( tmp <- c(1:8,NA,NA) )

## percentages excluding NA values
perc(tmp,5)
perc(tmp,5,"gt")
perc(tmp,5,"leq")
perc(tmp,5,"lt")

## percentages including NA values
perc(tmp,5,na.rm=FALSE)
perc(tmp,5,"gt",na.rm=FALSE)
perc(tmp,5,"leq",na.rm=FALSE)
perc(tmp,5,"lt",na.rm=FALSE)

FSA

Simple Fisheries Stock Assessment Methods

v0.8.32
GPL (>= 2)
Authors
Derek Ogle [aut, cre] (<https://orcid.org/0000-0002-0370-9299>), Powell Wheeler [aut], Alexis Dinno [aut] (Provided base functionality of dunnTest())
Initial release
2021-1-15

We don't support your browser anymore

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