break_month: Break Time Into Blocks

View source: R/surv_group.R

break_monthR Documentation

Break Time Into Blocks

Description

Divides a time duration into specified blocks. This function is useful for creating intervals or categories within a given time period, such as months or days, for further analysis or visualization in studies where time segmentation might be relevant.

Usage

break_month(input, block = 6, time_type = "month")

Arguments

input

A numeric vector representing time durations that need to be divided, typically in months or days.

block

An integer specifying the number of blocks to divide the time into; default is 6.

time_type

A character string specifying the units of the input time: "month" for months and "day" for days. The default is "month". If "day" is specified, the function converts days into months by dividing by 30.

Value

A numeric vector representing the breakpoints for the time blocks, rounded to the nearest multiple of 5.

Author(s)

Dongqiang Zeng

Examples

# Example with time in months
time_data <- c(24, 36, 12, 48)
blocks <- break_month(input = time_data)
print(blocks)

# Example with time in days
day_data <- c(720, 1080, 360, 1440)  # Corresponding to 24, 36, 12, 48 months
blocks_days <- break_month(input = day_data, time_type = "day")
print(blocks_days)

IOBR/IOBR documentation built on July 16, 2025, 8:12 p.m.