as.period: Time Period

Description Usage Arguments Details Value Examples

View source: R/funcs_2.R

Description

Transform time unit to period of time

Usage

1
as.period(times, period.length, numeric = TRUE, origin = NULL)

Arguments

times

Vector of calendar times (elapsed from the begining of the study) to transform to periods. Dates are also allowed but origin argument must be given then.

period.length

Length of each time period.

numeric

Logical. If TRUE, returns the periods as a numeric. Defaults to TRUE

origin

Date at which the trial began. Ignored unless times are dates.

Details

Time periods are closed on the right, and 0 is included in the first one. Period labels, when numeric is FALSE, come from cut.

Value

Returns a character (or numeric when numeric = TRUE) vector of length values with the corresponding time periods for each time.

Examples

1
2
3
as.period(c(0, 10, 89, 90, 91, 200), period.length = 90, numeric = TRUE)
as.period(c(0, 10, 89, 90, 91, 200), period.length = 90, numeric = FALSE)
as.period(as.Date("10-2-2000", "%d-%m-%Y"), period.length = 90, origin = as.Date("01-1-2000", "%d-%m-%Y"))

gcastella/predRCT documentation built on May 16, 2019, 10:15 p.m.