stdeviation: Calculating the Standard Deviation

Description Usage Arguments Value Examples

Description

Calculates the standard deviation. By selecting sample = TRUE, the user chooses to calculate the sample standard deviation, where the sum of square is divided by n-1. By selecting sample = FALSE, the calculation is treated as a population standard deviation, and the sum of squares is divided by n.

Usage

1
stdeviation(input, na.rm = FALSE, sample = TRUE)

Arguments

input

a vector of numbers

na.rm

true or false for removing NAs from the vector before calculations

sample

true or false where true represents a sample standard deviation and false represents a population standard deviation

Value

A number

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
a <- c(2,4,6,8)
stdeviation(a)

b <- c(NA,2,4,NA,8)
stdeviation(b)

d <- c(NA,2,4,NA,8)
stdeviation(d,na.rm=T)

e <- c(NA,2,4,8,NA)
stdeviation(e,na.rm=T,sample=F)

Andy-McCarthy/BasicMath documentation built on May 27, 2019, 7:24 a.m.