cohort: S3 class for cohort datasets (one row per patient)

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/cohort.R

Description

A class for ‘cohort’ datasets for use in epidemiological studies.

Usage

1
cohort(x, idcolname = c("patid", "anonpatid", "id"), description = NULL)

Arguments

x

a data.frame, ffdf or data.table which contains data on patients, one row per patient

idcolname

the column name representing the unique patient identifier

description

a data.frame with two columns containing column descriptions. The column names must be 'colname' and 'description'.

Details

Cohort objects have a number of associated methods which make it easier to manage data and generate datasets for analysis. Note that data.table objects are not copied by this function; the original object is modified. If you want to leave the original object as it is, use the copy function, e.g. mycohort <- cohort(copy(mydataset)).

Value

An object with classes ‘cohort’ and either ‘data.table’ or ‘ffdf’, and the following attributes:

idcolname

ID column name

description

description of the columns

If it is a data.table cohort, the ID column is the leftmost column and all the others are arranged alphabetically.

Author(s)

Anoop Shah

See Also

print.cohort, summary.cohort, merge.cohort

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
DT <- cohort(data.table(anonpatid = 1:3,
    indexdate = as.IDate(c("2012-1-3", "2012-1-2", "2010-1-9"))))
print(DT)
summary(DT)

FFDF <- as.ffdf(data.table(anonpatid = 1:3,
    indexdate = as.IDate(c("2012-1-3", "2012-1-2", "2010-1-9"))))
FFDF <- cohort(FFDF)
print(FFDF)
summary(FFDF)

CALIBERdatamanage documentation built on Nov. 23, 2021, 3 p.m.