modifyDescription {CALIBERdatamanage}R Documentation

Modify the description table for a data.frame, ffdf, data.table or matrix object.

Description

Cohort objects (see cohort) contain a description table as an attribute, which can be used to store column descriptions. purgeDescription removes description entries for non-existent columns.

Usage

modifyDescription(x, colname, description)
purgeDescription(x)

Arguments

x

a data.frame, ffdf, data.table or matrix object.

colname

vector of column names

description

vector of new descriptions

Value

Both functions invisibly return the modified object and update it by reference.

Author(s)

Anoop Shah

See Also

cohort

Examples

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

modifyDescription(COHORT, 'indexdate', 'date when the patient presented')
modifyDescription(COHORT, 'another', 'a non-existent column')
summary(COHORT)
# Cohort with 3 patients.
# ID column: anonpatid
# 
# COLUMN DESCRIPTIONS
# another (NULL): a non-existent column
# indexdate (IDate): date when the patient presented
# Warning message:
# In modifyDescription(COHORT, "another", "a non-existent column") :
#   another not in cohort

purgeDescription(COHORT)
summary(COHORT)
# Cohort with 3 patients.
# ID column: anonpatid
# 
# COLUMN DESCRIPTIONS
# indexdate (IDate): date when the patient presented

# Description for a matrix object
a <- matrix(1:4, nrow = 2, ncol = 2)
colnames(a) <- c('This', 'That')
a <- modifyDescription(a, 'This', 'This is the first column')
a <- modifyDescription(a, c('This', 'That'),
	c('This is the first column', 'That is the second column'))

[Package CALIBERdatamanage version 0.1-14 Index]