Learn R Programming

berryFunctions (version 1.21.2)

groupHist: Histogram for classes

Description

Improvement of tapply(x, g, hist) with x and g taken from a data.frame

Usage

groupHist(
  df,
  x,
  g,
  xlab = "",
  ylab = "",
  breaks = 20,
  las = 1,
  main = NULL,
  unit = NA,
  col = "purple",
  ...
)

Arguments

df

data.frame object name

x

column name of variable of interest

g

column name of groups (INDEX in tapply, f in split)

xlab, ylab

axis labels. DEFAULT: ""

breaks

hist breaks. DEFAULT: 20

las

LabelAxisStyle, see par. DEFAULT: 1, means numbers on y-axis upright

main

Main title, internal default based on d, x, unit and g. DEFAULT: NULL

unit

Unit to be written into the default title. DEFAULT: NA

col

Color vector to be used, recycled.

further arguments passed to hist

Value

NULL, used for plotting

Details

Uses split to categorize into groups.

See Also

hist, tapply

Examples

Run this code
# NOT RUN {
groupHist(chickwts, weight, "feed", col="salmon")
groupHist(chickwts, "weight", "feed", col=2, unit="grams at age 6 weeks")
groupHist(chickwts, weight, feed, col="khaki", breaks=5, main="Hi there")
groupHist(iris, Petal.Width, Species)

# }

Run the code above in your browser using DataLab