Learn R Programming

intsvy (version 2.9)

plot.intsvy.table: Graphical representation of frequency tables

Description

Functions pisa.table and piaac.table produce object of the class intsvy.table. The function plot.intsvy.table presents this table graphically.

Usage

# S3 method for intsvy.table
plot(x, se=FALSE, stacked=FALSE, centered = FALSE, midpoint = NA, ...)

Value

Returns object of ggplot class with barplot. Works for one way, two-way and three-way contingency tables.

Arguments

x

An object of the class intsvy.table returned by pisa.table or piaac.table functions.

se

If TRUE add whiskers for standard errors (only for stacked=FALSE).

stacked

If TRUE plot bars stacked one over another.

centered

If TRUE then bars will be centered around midpoint.

midpoint

A single number, which specifies the segment around which bars are centered. By default it's the middle segment calculated as (n.levels + 1)/2. If n.levels is odd then bars are centered around the beginning of the selected segment. If n.levels is even then bars are centered around the middle of the selected segment.

...

Not used. Required for cran-check.

See Also

plot.intsvy.mean, plot.intsvy.reg

Examples

Run this code
if (FALSE) {
# install pbiecek/PIAAC package from github to have access to piaac data
# age distribution in whole dataset
(ptable <- piaac.table(variable="AGEG10LFS", data=piaac))

# age distribution in whole dataset
plot(ptable)
plot(ptable, centered=TRUE)

# age distribution within countries
head(ptableC <- piaac.table(variable="AGEG10LFS", by="CNTRYID", data=piaac))

# age distribution within countries
plot(ptableC, stacked=TRUE)
plot(na.omit(ptableC), centered=TRUE)

# age distribution within countries and gender segments
head(ptableCA <- piaac.table(variable="AGEG10LFS", by=c("CNTRYID", "GENDER_R"), data=piaac))

# age distribution within countries and gender segments
plot(na.omit(ptableCA), stacked=TRUE)
plot(na.omit(ptableCA), centered=TRUE)

}

Run the code above in your browser using DataLab