hist2: Alternative to base hist function (using dplyr)

Description Usage Arguments Value Examples

View source: R/demonanalysis.R

Description

Alternative to base hist function (using dplyr)

Usage

1
hist2(x, breaks, counts = 1)

Arguments

x

a vector of values for which the histogram is desired

breaks

a vector giving the breakpoints between histogram bins

counts

optional vector of counts for each x value

Value

data frame with counts and densities

Examples

1
2
3
4
5
6
7
8
9
freq <- seq(0, 1, length = 20)
num <- rbinom(20, 10, 0.5)
breaks <- seq(0, 1, length.out = 5)
hist2(freq, breaks, num)
hist2(freq, breaks)

# equivalent using standard function:
hist(rep(x = freq, times = num), breaks, plot = FALSE)
hist(freq, breaks, plot = FALSE)

robjohnnoble/demonanalysis documentation built on June 30, 2020, 12:47 a.m.