ahist: Average shifted histogram

Description Usage Arguments Value Examples

View source: R/averaged_shifted_histograms.R

Description

Create a smoothed histogram by averaging several histograms shifted by fractions of a bin-width

Usage

1
2
3
ahist(x, n.breaks = nclass.FD(x), n.shifts = 3, type = c("histogram",
  "polygon", "line", "table"), freq = FALSE, plot = TRUE,
  add = FALSE, ...)

Arguments

x

a vector of values for which the histogram is desired

n.breaks

an integer giving the number of bins to be used

n.shifts

an integer giving the number of shifts to be performed

type

if plot=TRUE, the type of plot to be used

freq

should frequency counts be used, or density (default)

plot

logical; if TRUE (default), a graphical output will be returned

add

logical; if TRUE the plot will be added to the current plot

...

further graphical parameters to ymse::plot.histogram, polygon, or lines

Value

an object of class "histogram"

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
set.seed(1)
n <- 6

x <- sample(sample(0:20, 8), 6*n, replace=TRUE) + rnorm(6*n, -8, 0.5)
x <- c(x, rgamma(5*n, 3, 0.5), rnorm(4*n, 15, 2))
x <- round(x*5)/5

hist(x, freq=FALSE, breaks="FD", col="lightblue")
ahist(x, type="hist", border=2, col=7, freq=FALSE, lwd=2)
ahist(x, type="poly", border=2, col=7, freq=FALSE, lwd=2)
ahist(x, type="line", col=2, freq=FALSE, lwd=2)
ahist(x, type="table", col=2, freq=FALSE, lwd=2)
ahist(x, plot=FALSE)

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.