Skip to contents

A function to convert number of days into either number of weeks, months or years with specific bin values.

Usage

convert_number_days(
  x,
  unit = "month",
  bin = 1,
  digits = 2L,
  adjust_negative_value = FALSE
)

Arguments

x

Numeric vector

unit

Unit of measurements: either week, month or year, Default: 'month'

bin

Bin value, Default: 1

digits

Rounding decimal digits, Default: 2L

adjust_negative_value

Indicator to adjust for negative value

Value

A numeric vector

Details

A small positive values will be added to zero numeric value, specially to adjust time interval for baseline visits. Furthermore, all negative values will be replaced with the same small positive value (i.e., 1/(interval * bin)) if adjust_negative_value is set to TRUE

See also

Other Utility functions used for preparing analysis data: get_numeric_dx_status()

Examples

if (FALSE) { # \dontrun{
set.seed(123456)
x <- rnorm(100, mean = 100, sd = 10)
# Convert number of days into number of weeks
convert_number_days(x = x, unit = "week", bin = 1, digits = 1L)
# Convert number of days into number of months binned into 3 months
convert_number_days(x = x, unit = "month", bin = 3, digits = 2L)
# Convert number of days into number of years
convert_number_days(x = x, unit = "year", bin = 1, digits = 5L)
} # }