describeDate: Describe a date

View source: R/utils2.R

describeDateR Documentation

Describe a date

Description

A function that returns the range of a date object.

Usage

describeDate(x, format = "%b %d, %Y", copula = " to ", FUN = range)

describeDateBy(
  x,
  by,
  format = "%b %d, %Y",
  copula = " to ",
  FUN = range,
  add_total_col = TRUE,
  useNA = c("ifany", "no", "always"),
  useNA.digits = 0L,
  percentage_sign = FALSE
)

Arguments

x, by

vectors of dates and the variable to split x by

format

the date format; see strptime

copula

character string to separate the range

FUN

a function to summarize x, usually range or min

add_total_col

logical, "first", or "last"; adds the total column to the output

useNA

how to handle missing values, one of "ifany" (default), "no", or "always"

useNA.digits

number of digits to use for missing percentages

percentage_sign

logical; if TRUE, percent signs are added

See Also

getDescriptionStatsBy

Examples

x <- c(1:4, NA, 5)
d <- as.Date(x, origin = Sys.Date())
y <- c(1, 1, 2, 2, 1, 3)
describeDate(x)
describeDateBy(d, y, copula = ' - ', format = '%d %B')
describeDateBy(d, y, percentage_sign = TRUE, useNA.digits = 2, FUN = min)

dd <- data.frame(x, y, d)
tabler_stat(dd, 'd', 'y')
tabler_stat2(dd, c(Integer = 'x', Date = 'd'), c(Byvar = 'y'))


raredd/rawr documentation built on March 4, 2024, 1:36 a.m.