vignette_mtb_time_related

Y. Hsu

2021-11-15

library(mtb)

Background

It’s common to have observations that were measured longitudinally. Here are some functions that could present observations measured over time.

How to use

This is a basic example which shows you how to plot intervals of events with group labels at the beginning of individual intervals.

dt = data.frame( id=paste('ID', c(seq(1,5),seq(1,5)),sep=""), idn=c(seq(1,5),seq(1,5)), start=1800*seq(1,10)/3, end=1800*(seq(1,10)/3+seq(2,-2)), label=rep(c('A','B'),5) )
dt
#>     id idn start  end label
#> 1  ID1   1   600 4200     A
#> 2  ID2   2  1200 3000     B
#> 3  ID3   3  1800 1800     A
#> 4  ID4   4  2400  600     B
#> 5  ID5   5  3000 -600     A
#> 6  ID1   1  3600 7200     B
#> 7  ID2   2  4200 6000     A
#> 8  ID3   3  4800 4800     B
#> 9  ID4   4  5400 3600     A
#> 10 ID5   5  6000 2400     B
p=time_plot_interval( dt, xlab='Time', ylab='ID', legend_title='Group', arrow_wt=2, arrow_color='gray')
p