Last data update: 2014.03.03

R: Draws Lexis diagram with lifelines for selected subjects
Lexislines.episodesR Documentation

Draws Lexis diagram with lifelines for selected subjects

Description

The function draws a Lexis diagram, using the Lexis object defined in the Epi package, and draws lifelines for selected subjects.

Usage

Lexislines.episodes(Bdata,Dlong, subjectsID, title)

Arguments

Bdata

Biograph object

Dlong

Input data in long format

subjectsID

Lifelines are drawn for subjects, identified by ID, included in the vector subjectsID.

title

Title of the Lexis diagram.

Details

The function produces a Lexis object and plots the object for selected subjects. Transitions are marked on the lifelines. It requires data in long format. If the long format is not available, the function calls the function Biograph.long to produce the required format.

Value

Lcoh11

Lexis object that includes all subjects

Lcohh12

Lexis object that includes selected subjects

sub

vector of IDs of subjects selected for the lifelines in the Lexis diagram

k

Number of subjects selected

Note

requires Epi

Author(s)

Frans Willekens

References

Plummer, M. and B. Carstensen (2011) Lexis: an R class for epidemiolgoical studies with long-term follow-up. Journal of Statistical Software, 38(5):1-12

Carstensen, B. (2009) The Epi package. Available at http://cran.r-project.org/web/packages/Epi/Epi.pdf

See Also

Lexis.lines

Examples

#  Example 1: Employment careers
  data(GLHS) 
  z<- Parameters (GLHS)
  D <- Biograph.long (GLHS)
  tit5 <- "Employment careers for a selection of subjects. GLHS"
  subjects <- c(1,78,120,208)
  z <- Lexislines.episodes (Bdata=GLHS,Dlong=D$Depisode,subjectsID = subjects,title = tit5)

#  Example 2: Long data format need to be obtained
  z <- Lexislines.episodes (Bdata=GLHS,subjectsID = subjects,title = tit5)  

#  Example 3: Living arrangements 
  data(NLOG98)
  z<- Parameters (NLOG98)
  D <- Biograph.long (NLOG98)
  tit5 <- "Living arrangements for a selection of subjects, NLOH98"
  subjectsID <- c(8,96,980,1056,1496,2883)
  z <- Lexislines.episodes (NLOG98,D$Depisode,subjectsID = subjectsID,title = tit5)

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/Lexislines.episodes.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Lexislines.episodes
> ### Title: Draws Lexis diagram with lifelines for selected subjects
> ### Aliases: Lexislines.episodes Lexislines
> 
> ### ** Examples
> 
> #  Example 1: Employment careers
>   data(GLHS) 
>   z<- Parameters (GLHS)
[1] ". . . . Running function Parameters . . . . "
[1] "Exploring types of transitions"
>   D <- Biograph.long (GLHS)
[1] . . . . .  Creating long format  . . . . . .
[1] . . . . .  running reshape  . . . . . 
[1]  . . . . Sort data in long format  . . . . 
[1]  . . . . Adjust long format for survival package etc . . .  
>   tit5 <- "Employment careers for a selection of subjects. GLHS"
>   subjects <- c(1,78,120,208)
>   z <- Lexislines.episodes (Bdata=GLHS,Dlong=D$Depisode,subjectsID = subjects,title = tit5)
> 
> #  Example 2: Long data format need to be obtained
>   z <- Lexislines.episodes (Bdata=GLHS,subjectsID = subjects,title = tit5)  
[1] Getting data in long file format. Patience please.
[1] . . . . .  Creating long format  . . . . . .
[1] . . . . .  running reshape  . . . . . 
[1]  . . . . Sort data in long format  . . . . 
[1]  . . . . Adjust long format for survival package etc . . .  
[1] "Data in long format produced. Lexis continues."
> 
> #  Example 3: Living arrangements 
>   data(NLOG98)
>   z<- Parameters (NLOG98)
[1] ". . . . Running function Parameters . . . . "
[1] "Exploring types of transitions"
>   D <- Biograph.long (NLOG98)
[1] . . . . .  Creating long format  . . . . . .
[1] . . . . .  running reshape  . . . . . 
[1]  . . . . Sort data in long format  . . . . 
[1]  . . . . Adjust long format for survival package etc . . .  
>   tit5 <- "Living arrangements for a selection of subjects, NLOH98"
>   subjectsID <- c(8,96,980,1056,1496,2883)
>   z <- Lexislines.episodes (NLOG98,D$Depisode,subjectsID = subjectsID,title = tit5)
Warning message:
In Lexis(id = Dlong2$ID, entry = list(CalTime = en1), exit = list(CalTime = ex1,  :
  Dropping 1 rows with duration of follow up < tol

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>