markVisits {epicalc}R Documentation

Mark visits of subjects in a long format

Description

Mark visits of subjects in a longitudinal data frame

Usage

markVisits(id, time)

Arguments

id subject identification field
time time of visit

Details

Visit numbers are essential in longitudinal data analysis. This function make it easy for R user to do so.

If visits marked by this function is going to be further used for calculation of lag difference, there must not be any missing visit in the data set.

Note

This was created from combination of the functions 'rle' and 'sapply'

Author(s)

Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>

See Also

'rle', 'sapply'

Examples

## Data frame
data(Sitka, package="MASS")
use(Sitka)

## Classical R methods
list1 <- rle(tree)
list1
visit1 <- unlist(sapply(X=list1$lengths, FUN=function(x) 1:x, simplify=FALSE))
visit1

## Do it again by Epicalc
visit2 <- markVisits(id=tree, time=Time)
visit2

[Package epicalc version 2.10.1.1 Index]