textplot_bar: Barplot of a frequency table using lattice

View source: R/textplot_bar.R

textplot_barR Documentation

Barplot of a frequency table using lattice

Description

Barplot of a frequency table using lattice

Usage

textplot_bar(x, ...)

## Default S3 method:
textplot_bar(
  x,
  panel = "Effect",
  total = sum(x),
  top = 40,
  col.panel = "lightgrey",
  col.line = "lightblue",
  lwd = 3,
  cextext = 0.5,
  addpct = FALSE,
  cexpct = 0.75,
  textpos = 3,
  pctpos = 1,
  v = NULL,
  col.abline = "red",
  ...
)

Arguments

x

a table to plot or a data.frame with the first column the label and the second column the frequency

...

other arguments passed on to lattice::dotplot

panel

character string what to put into the panel

total

integer with the total. Defaults to sum(x). Is used to plot the table counts as a percentage. In which case this is divided by the total.

top

integer indicating to plot only the first 'top' table elements. Defaults to 40.

col.panel

color of the panel. Defaults to lightgrey.

col.line

color of the line. Passed on to the col argument in lattice::panel.lines

lwd

width of the line. Passed on to the lwd argument in lattice::panel.lines

cextext

numeric with the cex of the text with the counts plotted. Passed on to lattice::panel.text.

addpct

logical indicating to add the percent with lattice::panel.text

cexpct

numeric with the cex of the text plotted when using addpct. Passed on to lattice::panel.text.

textpos

passed on to the pos argument of panel.text to indicate where to put the text of the frequencies

pctpos

passed on to the pos argument of panel.text to indicate where to put the text of the percentages

v

passed on to lattice::panel.abline to draw a vertical line

col.abline

passed on to lattice::panel.abline to draw a vertical line

Value

the result of a call to lattice::dotplot

Examples


data(brussels_listings, package = 'udpipe')
x <- table(brussels_listings$neighbourhood)
x <- sort(x)
textplot_bar(x,
 panel = "Locations", col.panel = "darkgrey", xlab = "Listings",
 cextext = 0.75, addpct = TRUE, cexpct = 0.5)


x <- sample(LETTERS, 1000, replace = TRUE)
textplot_bar(sort(table(x)), panel = "Frequencies", xlab = "Frequency",
   cextext = 0.75, main = "Freq stats")
textplot_bar(sort(table(x)), panel = "Frequencies", addpct = TRUE, top = 15)

## x can also be a data.frame where the first column
## is the label and the second column the frequency
x <- data.frame(l = LETTERS, amount = rnorm(26))
textplot_bar(x)
textplot_bar(x, v = 0)

textplot documentation built on July 18, 2022, 1:05 a.m.