pct {MSMU}R Documentation

Percent Within N Standard Deviations of the Mean

Description

Calculates the percentage of values in a numeric vector that fall within n standard deviations of the mean.

Usage

pct(x, n)

Arguments

x

A numeric vector.

n

A positive numeric value indicating how many standard deviations from the mean to use as bounds.

Value

A single numeric value representing the percentage (0–100) of values within the specified range.

Examples

# Percentage of values that fall within 2 sds of the mean in random normal data
set.seed(123)
x <- rnorm(1000)
pct(x,2)

# Percentage of values that fall within 2 sds of the mean in iris Sepal Lengths
data("iris")
pct(iris$Sepal.Length, 2)



[Package MSMU version 0.1.2 Index]