Learn R Programming

Biograph (version 1.0)

StackGraph: Plot state occupancies by age

Description

Plots counts or proportion of people in each state, by age.

Usage

StackGraph(x, xlabel, ylabel, xlegend, ylegend, title_main, title_sub, namst)

Arguments

x
An object with state occupancies, produced by the Occup function or the multistate life table.
xlabel
Label of the x-axis.
ylabel
Label of the y-axis.
xlegend
The position of the legend on the x-axis.
ylegend
The position of the legend on the y-axis.
title_main
The main title.
title_sub
A subtitle. The subtitle is shown at the bottom of the graph.
namst
The legend. A vector of labels for each category.

Details

The function uses the barplot function of the R graphics package.

Examples

Run this code
data (GLHS)
	occup <- Occup (GLHS)
	tit1 <- "State occupancies by age. GLHS"
	tit2<- "Data from cohorts 1929-31, 1939-41 and 1949-51"
	namstates2 <- c(namstates,"censored")
	z <- StackGraph (x=occup$state_occup[,1:(numstates+1)],
         	xlabel="Age",
			ylabel="State Occupancies",
			xlegen=0,
			ylegend=nsample,
			title_main=tit1,
			title_sub=tit2,
			namst=namstates2)

Run the code above in your browser using DataLab