addnorm: addnorm - adds a normal distribution to a histogram of a data...

View source: R/datalow_utils.r

addnormR Documentation

addnorm - adds a normal distribution to a histogram of a data set.

Description

addnorm - adds a normal distribution to a histogram of a data set. This is generally to be used to illustrate whether log-transformation normalizes a set of catch or cpue data.

Usage

addnorm(inhist, xdata, inc = 0.01)

Arguments

inhist

- is the output from a call to 'hist' (see examples)

xdata

- is the data that is being plotted in the histogram.

inc

- defaults to a value of 0.01; is the fine grain increment used to define the normal curve. The histogram will be coarse grained relative to this.

Value

a list with a vector of 'x' values and a vector of 'y' values (to be used to plot the fitted normal probability density function), and a vector used two called 'stats' containing the mean and sandard deviation of the input data

Examples

x <- rnorm(1000,mean=5,sd=1)
dev.new(height=6,width=4,noRStudioGD = TRUE)
par(mfrow= c(1,1),mai=c(0.5,0.5,0.3,0.05))
par(cex=0.85, mgp=c(1.5,0.35,0), font.axis=7)
outH <- hist(x,breaks=25,col=3,main="")
nline <- addnorm(outH,x)
lines(nline$x,nline$y,lwd=3,col=2)
print(nline$stats)

haddonm/datalowSA documentation built on Nov. 5, 2023, 6:40 p.m.