cohortmethods: Functions for handling cohort objects

Description Usage Arguments Value Author(s) See Also Examples

Description

Functions for printing, subsetting and merging cohort objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
as.cohort(x, ...)
is.cohort(x)

## S3 method for class 'cohort'
print(x, ...)
## S3 method for class 'cohort'
summary(object, ...)
## S3 method for class 'cohort'
subset(x, subset, select, ...)
## S3 method for class 'cohort'
merge(x, y, by = attr(x, "idcolname"), ...)

Arguments

x

a cohort object

object

a cohort object

y

another cohort object

subset

expression denoting which rows to keep. It is interpreted within the environment of the cohort data.table, so columns can be referred to directly by name

select

vector of column names for columns to keep. The ID column is always selected.

by

character vector of column names to merge by. Defaults to the ID column of x.

...

additional arguments

Value

as.cohort coerces its argument to a cohort if possible. If it is already a data.table, it is updated by reference, and the new name will be an alias to the existing object. Use copy = TRUE explicitly to create a cohort object without altering the original object.

is.cohort returns TRUE or FALSE according to whether the class of the object is cohort

The summary method displays the description table to the console.

The print method displays the description table and the data itself, in the way that a data.table is displayed.

The subset method returns a cohort object which contains a subset of the original cohort.

The merge method returns a merged cohort containing x and y merged on the ID column. Both cohort objects must have the same ID column, otherwise they cannot be merged.

Author(s)

Anoop Shah

See Also

cohort, removeColumns

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# data.table cohort
COHORT <- cohort(data.table(anonpatid = 1:3, indexdate = as.IDate(c("2012-1-3", 
	"2012-1-2", "2010-1-9"))))
COHORT2 <- cohort(data.table(anonpatid = 1:3, disease = c(TRUE, FALSE, TRUE)))
is.cohort(COHORT)
subset(COHORT, anonpatid == 2)
summary(COHORT)
merge(COHORT, COHORT2)

COHORT <- as.ffdf(COHORT)
COHORT2 <- as.ffdf(COHORT2)
is.cohort(COHORT)
subset(COHORT, as.ram(COHORT$anonpatid == 2))
merge(COHORT, COHORT2)

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