Learn R Programming

plotrix (version 1.41)

plot.freq: Plot a frequency table

Description

Plots a horizontal bar plot of a "freq" object.

Usage

plot.freq(x,main=NULL,col=NULL,show.prop=TRUE,show.pc=FALSE,show.labels=FALSE,
  show.axis=FALSE,...)

Arguments

x
a frequency table produced by freq
main
main title of the plot
col
vector of colors to use as fills for the bars - defaults to 1:nbars+1.
show.prop
whether to display the proportions or percentages on each bar
show.pc
whether to display percentages instead of proportions
show.labels
whether to display the value labels on each bar
show.axis
whether to display a horizontal axis below the bars
...
additional arguments passed to plot.

Value

  • nil

Details

plot.freq will accept a list of frequencies produced by freq and display a horizontal barplot in which each horizontal stack of bars represents one component of the list. The length of each bar is proportional to the frequency of that value in the list.

See Also

freq

Examples

Run this code
testdat.df<-data.frame(Sex=sample(c("Male","Female"),142,TRUE),
  Marital=sample(c("Divorced","Married","Single","De facto","Widowed"),142,TRUE),
  SES=c(sample(c("Low","Middle","High"),130,TRUE),rep(NA,12)),
  Age=sample(c("0-20","21-40","41-60","61-80","over 80"),142,TRUE))
 testdat.freq<-freq(testdat.df)
 plot.freq(testdat.freq,show.labels=TRUE,show.axis=TRUE)

Run the code above in your browser using DataLab