modifyDescription: Modify the description table for a data.frame, ffdf,...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/modifyDescription.R

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

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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'))

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