plot-methods: acs Methods for Function 'plot'

Description Usage Arguments Methods Examples

Description

Plot acs objects, with both estimates and confidence intervals.

Usage

1
2
3
4
## S4 method for signature 'acs'
plot(x, conf.level=.95, err.col="red", err.lwd=1,
err.pch="-", err.cex=2, err.lty=2, x.res=300, labels="auto",
by="geography", true.min=T, ...)

Arguments

x

the acs object to be plotted

conf.level

the desired confidence interval to use for error bars; numeric between 0<1

err.col

the color to use for the error bars; analogous to graphic parameter col

err.lwd

the line weight to use for the error bars; analogous to graphic parameter lwd

err.pch

the point character to use for the error bars; analogous to graphic parameter pch

err.cex

the scaling factor to use for the error bars; analogous to graphic parameter cex

err.lty

the line type to use for the error bars; analogous to graphic parameter lty

x.res

when plot called with a single acs value (see below), x.res determines the resolution of the resulting density plot; integer (defaults to 300, i.e., the curve is drawn with 300 points)

labels

the labels to use for the x axis; defaults to either geography names or acs.colnames based on dimensions of object plotted; vector of proper length required

by

in cases where multiple rows and columns are plotted, whether to provide a different plot for each value of geography (the default) or acs.colnames; accepts either "geography" or "acs.colnames"

true.min

whether to limit the lower bound of a confidence interval to some value or now; TRUE (the default) allows for negative lower bounds; also accepts FALSE to limit lower bounds to 0, or any number, to use that as a minimum lower bound; see details.

...

provided to allow for passing of additional arguments to plot functions

Methods

signature(object = "acs")

When passed an acs object (possibly involving subsetting), plot will call a plot showing both estimates and confidence intervals for the data contained in the object.

If the object contains only one row or only one column, plot will use this dimension as the y-axis and will plot each observation along the x-axis, as three points (an estimate bracketed by upper and lower confidence bounds). If the object contains multiple rows and columns, plot will return a 1-by-y "plot of plots": by default there will be one plot per row showing all the data for each geography, although this can be changed by specifying by="acs.colnames", to plot each variable as its own plot, with all of the geographies along the x-axis.

In the special case where the dimensions of the object are exactly c(1,1) (i.e., a single geography and column), plot will return a density plot of the estimate. In this case, conf.level, err.col, err.lty, and err.lwd will be used to determine the properties of the margins of error lines. (For none, use conf.level=F. For these density plots, users may also wish to set xlim and x.res, which specify the horizontal extent and resolution of the plot.)

plot accepts many of the standard graphical arguments to plot, such as main, sub, xlab, pch, and col, as well new ones listed above.

In some cases, the lower bound of a confidence interval may extend below 0; in some cases this is desired, especially when a variable is actually stating the difference between two estimates. In other cases, this may seem confusing (for example, when reporting the estimated count in a particular category). Setting true.min to FALSE (or 0) will limit the lower boundary of any confidence intervals computed and plotted.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# load ACS data
data(kansas07)

# plot a single value
plot(kansas07[4,4])

# plot by geography
plot(kansas07[,10])

# plot by columns
plot(kansas07[4,3:10])

# a density plot for a single variable
plot(kansas07[7,10])

# same, using some graphical parameters
plot(kansas07[7,10], col="blue", err.col="purple", err.lty=3)

plot(kansas07[7,49], col="lightblue", type="h", x.res=3000,
err.col="purple", err.lty=3, err.lwd=4, conf.level=.99,
main=(paste("Distribution of Females>85 Years in ",
geography(kansas07)[7,1], sep="")),
sub="(99-percent margin of error shown in purple)")

# something more complicated...

plot(kansas07[c(1,3,4),3:25], err.col="purple",
pch=16, err.pch="x", err.cex=1, ylim=c(0,5000),
col=rainbow(23), conf.level=.99,
labels=paste("grp. ",1:23))

acs documentation built on May 1, 2019, 8:41 p.m.