Learn R Programming

VGAM (version 1.1-9)

spikeplot: Spike Plot

Description

Produces a spike plot of a numeric vector.

Usage

spikeplot(x, freq = FALSE, as.table = FALSE, col = par("col"),
    lty = par("lty"), lwd = par("lwd"), lend = par("lend"),
    type = "h", xlab = deparse1(substitute(x)), ylab = NULL,
    capped = FALSE, cex = sqrt(lwd) / 2, pch = 19, pcol = col, scol = NULL,
    slty = NULL, slwd = NULL, new.plot = TRUE, offset.x = 0, ymux = 1, ...)

Value

Returns invisibly table(x).

Arguments

x

Numeric, passed into table.

freq

Logical. If TRUE then the y-axis measures the frequencies, else the sample proportions. Intended to be as hist.

as.table

Logical. If TRUE then the call to plot is closer to plot(table(x), ...), meaning the labelling differs from as.table = FALSE. The default is to convert table(x) into a numeric vector which is then passed into plot so that the labelling is more uniform along the x-axis.

col, type, lty, lwd

See par.

lend, xlab, ylab

See par.

capped, cex, pch, pcol

First argument is logical. If TRUE then the others argument are used to place points at the top using points with pcol being its colour. See par.

scol, slty, slwd

Similar to col, lty and lwd but apply to some selected values. The input may be a named list such as scol = list("green" = c(2, 4, 6), "blue" = 5), slty = list("dashed" = c(2, 4, 6), "dotted" = 5), slwd = list("2" = c(2, 4, 6), "3" = 5), else a named vector such as scol = c("green" = 2, "green" = 4, "green" = 6, "blue" = 5), slty = c("dashed" = 2, "dashed" = 4, "dashed" = 6, "dotted" = 5), slwd = c("2" = 2, "2" = 4, "2" = 6, "3" = 5). The three arguments are ignored if as.table = TRUE.

new.plot, offset.x

Logical and numeric. Add to an existing plot? If so, set new.plot = FALSE and it is useful for the spikes to be shifted by some amount offset.x.

ymux

Numeric, y-multiplier. The response is multiplied by ymux. This can be useful when plotting subsets side-by-side so that the constituent proportions add up to the overall proportion.

...

Additional graphical arguments passed into an ordinary plot, for example, xlim, las, main.

Author

T. W. Yee.

Details

Heaping is a very commonly occurring phenomenon in retrospective self-reported survey data. Also known as digit preference data, it is often characterized by an excess of multiples of 10 or 5 upon rounding. For this type of data this simple function is meant to be convenient for plotting the frequencies or sample proportions of a vector x representing a discrete random variable. This type of plot is known as a spike plot in STATA circles. If table(x) works then this function should hopefully work. The default for type means that any heaping and seeping should easily be seen. If such features exist then GAITD regression is potentially useful---see gaitdpoisson etc. Currently missing values are ignored totally because table(x) is used without further arguments; this might change in the future.

See Also

table, plot, par, deparse1, dgaitdplot, plotdgaitd, gaitdpoisson.

Examples

Run this code
if (FALSE) {
spikeplot(with(marital.nz, age), col = "pink2", lwd = 2)
}

Run the code above in your browser using DataLab