intervalKey: Representative String for Part of Timestamp

Description Usage Arguments Examples

View source: R/main.R

Description

Representative String for Part of Timestamp

Usage

1
intervalKey(tstamps, itype)

Arguments

tstamps

(vector of) timestamp(s) of type POSXIXt

itype

one of 'y' (year), 'q' (quarter in year), 'm' (month in year), 'd' (day in month in year), 'w' (week in year), 'D' (weekday in month in year), 'qo' (quarter only), 'mo' (month only), 'do' (day only), 'dm' (day in month), 'wo' (week only), 'Do' (weekday only), 'Dy' (weekday in year)

Examples

1
2
3
4
5
6
7
8
9
# Define a sequence of times
times <- as.POSIXct(kwb.datetime::sequenceOfTimestamps(
  "2017-11-04 22:00:00", "2017-11-05 02:00:00", step.s = 3000
))

# Apply all different defined types and print the result
for (type in rownames(kwb.datetime:::.timestamp_type_info())) {
  kwb.utils::printIf(TRUE, intervalKey(times, type), paste("\ntype:", type))
}

KWB-R/kwb.datetime documentation built on July 9, 2021, 10:28 p.m.