setData: Sets data according to a list of arguments.

View source: R/setData.R

setDataR Documentation

Sets data according to a list of arguments.

Description

Sets data according to a list of arguments.

Usage

setData(dat, Args = setArgs(), time2 = NULL, age_cut = NULL, birthdate = NULL)

Arguments

dat

A dataset to subset.

Args

Takes a list of arguments from setArgs.

time2

The name of a date variable that is used to calculate the Age variable using the getBirthDate function. Age is calculated as (time2 - birthdate)/365.35. If time2=NULL, the default, then setData will use an existing Age variable in dat.

age_cut

Vector of ages to make age categories from link{setArgs}.

birthdate

Takes the dataset generated from getBirthDate.

Value

data.frame

Examples

hiv <- getHIV()
Args <- setArgs(Age=list(All=c(15, 25)))
# This will use the existing Age variable to subset 
adat <- setData(hiv, Args)
# This will create a new Age variable using the birthdat and subset by age
adat1 <- setData(hiv, Args, time2="VisitDate", birthdate=getBirthDate())
# Note that there will be some discrepancy in the number of observations between adat and
adat1

vando026/ahri documentation built on Aug. 10, 2024, 3:20 p.m.