casebase (version 0.1.0)

checkArgsEventIndicator: Check that Event is in Correct Format

Description

Checks for event categories and gives a warning message indicating which level is assumed to be the reference level.

Usage

checkArgsEventIndicator(data, event, censored.indicator)

Arguments

data

a data.frame or data.table containing the source dataset.

event

a character string giving the name of the event variable contained in data. See Details. If event is a numeric variable, then 0 needs to represent a censored observation, 1 needs to be the event of interest. Integers 2, 3, ... and so on are treated as competing events. If event is a factor or character and censored.indicator is not specified, this function will assume the reference level is the censored indicator

censored.indicator

a character string of length 1 indicating which value in event is the censored. This function will use relevel to set censored.indicator as the reference level. This argument is ignored if the event variable is a numeric

Value

A list of length two. The first element is the factored event, and the second element is the numeric representation of the event

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
library(survival) # for veteran data
checkArgsEventIndicator(data = veteran, event = "celltype", censored.indicator = "smallcell")
checkArgsEventIndicator(data = veteran, event = "status")
checkArgsEventIndicator(data = veteran, event = "trt") # returns error

url <- "https://raw.githubusercontent.com/sahirbhatnagar/casebase/master/inst/extdata/bmtcrr.csv"
bmt <- read.csv(url)
checkArgsEventIndicator(data = bmt, event = "Sex", censored.indicator = "M")
checkArgsEventIndicator(data = bmt, event = "D", censored.indicator = "AML")
checkArgsEventIndicator(data = bmt, event = "D", censored.indicator = "AMLL") #returns error
checkArgsEventIndicator(data = bmt, event = "Source")
checkArgsEventIndicator(data = bmt, event = "Status")
checkArgsEventIndicator(data = bmt, event = "Status", censored.indicator = 3)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab