timeinterval: Time Interval Calculator

View source: R/timeinterval.h.R

timeintervalR Documentation

Time Interval Calculator

Description

Calculates time intervals between dates or from pre-calculated values. Time intervals form the basis of person-time follow-up calculations in survival analysis. Person-time follows the accumulated time that participants contribute to a study while being at risk for the event of interest, accounting for varying entry times and censoring. Person-time is typically expressed in person-days, person-months, or person-years depending on the study duration and outcome frequency.

Usage

timeinterval(
  data,
  dx_date,
  fu_date,
  time_format = "ymd",
  output_unit = "months",
  use_landmark = FALSE,
  landmark_time = 3,
  add_times = TRUE
)

Arguments

data

The data as a data frame.

dx_date

Column containing start dates

fu_date

Column containing end dates

time_format

.

output_unit

.

use_landmark

.

landmark_time

.

add_times

.

Value

A results object containing:

results$todo a html
results$personTimeInfo a html
results$summary a html
results$calculated_time an output

Examples

# Calculate time intervals for person-time analysis:
# timeinterval(
#   data = study_data,
#   dx_date = "diagnosis_date",
#   fu_date = "followup_date",
#   output_unit = "months"
# )


sbalci/jsurvival documentation built on July 4, 2025, 5:26 p.m.