Skip to contents

Event_Time_Gen generates event-time tables

Usage

Event_Time_Gen(
  table,
  pyr = list(),
  time_scale = list(),
  categ = list(),
  summaries = list(),
  events = c(),
  fcount = FALSE,
  lcount = FALSE,
  studyid = "studyID",
  verbose = FALSE
)

Arguments

table

dataframe with every category/event column needed

pyr

list with entry and exit lists, containing day/month/year columns in the table

time_scale

list with the time scale information, either a calendar category or an age category

categ

list with category columns and methods, methods can be either strings or lists of boundaries

summaries

list of columns to summarize, supports counts, means, and weighted means by person-year and renaming the summary column

events

list of events or interests, checks if events are within each time interval

fcount

boolean if the first at risk count should be returned in the data. Returns the number of observations starting in each combination of categories.

lcount

boolean if the last at risk count should be returned in the data. Returns the number of observations ending in each combination of categories.

studyid

id used to determine distinct subjects used for first and last at risk intervals.

verbose

boolean if updates should be printed to the console.

Value

returns a grouped table and a list of category boundaries used

See also

Other Table Generation Functions: Event_Count_Gen()

Examples

library(data.table)
a <- c(0, 1, 2, 3, 4, 5, 6)
b <- c(1, 2, 3, 4, 5, 6, 7)
c <- c(0, 1, 0, 0, 0, 1, 0)
d <- c(1, 2, 3, 4, 5, 6, 7)
e <- c(2, 3, 4, 5, 6, 7, 8)
f <- c(
  1900, 1900, 1900, 1900,
  1900, 1900, 1900
)
g <- c(1, 2, 3, 4, 5, 6, 7)
h <- c(2, 3, 4, 5, 6, 7, 8)
i <- c(
  1901, 1902, 1903, 1904,
  1905, 1906, 1907
)
table <- data.table::data.table(
  a = a, b = b, c = c,
  d = d, e = e, f = f,
  g = g, h = h, i = i
)
categ <- list(
  a = "-1/3/5]7"
)
calendar_categ <- list(
  type = "calendar",
  day = c(1, 1, 1),
  month = c(1, 1, 1),
  year = c(1901, 1904, 1908)
)
time_scale <- list("time" = calendar_categ)
summary <- list(
  c = "count AS cases"
)
events <- list("c")
pyr <- list(
  entry = list(year = "f"),
  exit = list(year = "i"),
  unit = "years"
)
e <- Event_Time_Gen(table, pyr, time_scale, categ, summary, events)