Given a single integer vector (with origin specified) or data class vector, will compute median day and a range (default min/max) and percent of total, returning results in string. Mostly called by other functions.

num_dt(x, median = TRUE, range='min/max', origin=NULL)

Arguments

range

A character string to indicate range values. options: 'min/max'.

origin

Default NULL. If specified, must be a date class object of length 1. For use if date variable is in raw integer format.

x

A integer or date class vector

nomedian

A logical vector, indicates whether to report median or not. Default = TRUE.

Value

A character string of length 1, 'Median date (date1, date2)'

Examples

require(mdsR)
#> Loading required package: mdsR
#> Loading required package: openxlsx
#> Loading required package: rlang
#> Warning: package 'rlang' was built under R version 3.5.2
#> #> Attaching package: 'rlang'
#> The following object is masked from 'package:data.table': #> #> :=
#> The following objects are masked from 'package:testthat': #> #> is_false, is_null, is_true
#> The following objects are masked from 'package:purrr': #> #> %@%, as_function, flatten, flatten_chr, flatten_dbl, flatten_int, #> flatten_lgl, flatten_raw, invoke, list_along, modify, prepend, #> splice
mds_dta <- mdsR::mds_cohort
#> Error: 'mds_cohort' is not an exported object from 'namespace:mdsR'
num_dt(mds_dta$dmdate)
#> [1] "2015-03-22 (2013-01-02, 2018-07-18)"