Plots state occupancies. It plots the state occupancies (counts in sample or population under observation) as estimated by Occup. The data are produced by the Occup function.
Usage
## S3 method for class 'occup.S'
plot(x,namstates.desired,colours,title,area,xmin,xmax,...)
Arguments
x
State occupancies in sample population, by age. An object of class occup.S produced by the Occup function.
namstates.desired
Desired sequence of states in plot. The argument is used to specify an informative
ordering of the state occupancies or state probabilities to be stacked.
colours
Colours selected to distinguish the states in the state space.
title
title of plot
area
logical variable.If area is TRUE, area plot is displayed (using geom_area of ggplot2). If area is FALSE, a bar plot is displayed (using geom_bar of ggplot2)
xmin
Minimum age in plot
xmax
Maximum age in plot
...
Further arguments to plot
Details
The function uses the ggplot2 package
Value
occup.S
State occupancies
plot
The figure of state occupancies
Author(s)
Frans Willekens
Examples
data(GLHS)
Bdata.a <- date_b (GLHS,format.out="age",covs=c("marriage","LMentry"))
occup <- Occup(Bdata.a)
dd <- occup$state_occup
t <- "States occupancies. GLHS"
cc <- c("red","green","lightgrey")
xx <- c("N","J","Censored")
z<- plot (x=dd,namstates.desired=xx,colours=cc,title=t,area=TRUE,xmin=10,xmax=55)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Biograph)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Biograph/plot.occup.S.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot.occup.S
> ### Title: Plots state occupancies
> ### Aliases: plot.occup.S
>
> ### ** Examples
>
> data(GLHS)
> Bdata.a <- date_b (GLHS,format.out="age",covs=c("marriage","LMentry"))
cmc_as_age: negative ages are replaced by NA
> occup <- Occup(Bdata.a)
[1] The number of age groups is 54
[1] ". . . . Running function Parameters . . . . "
[1] "Exploring types of transitions"
[1] ". . . . Running Occup . . . . "
[1] ". . . . Running function Parameters . . . . "
[1] "Exploring types of transitions"
[1] "state_time: compute state.n"
> dd <- occup$state_occup
> t <- "States occupancies. GLHS"
> cc <- c("red","green","lightgrey")
> xx <- c("N","J","Censored")
> z<- plot (x=dd,namstates.desired=xx,colours=cc,title=t,area=TRUE,xmin=10,xmax=55)
Warning messages:
1: Removed 30 rows containing missing values (position_stack).
2: Removed 1 rows containing missing values (geom_vline).
>
>
>
>
>
> dev.off()
null device
1
>