Learn R Programming

WebAnalytics (version 0.9.14)

posixctCut: Replacement For cut.POSIXct

Description

Cut replacementthat Returns POSUIXct type to avoid the lack of round-trip support in POSIXt types between Cut, as character and as.POSIXXct

Usage

posixctCut(timeVector, interval)

Value

Returns a vector of POSIXct types, cut to the intervals specified.

Arguments

timeVector

vector of POSIXt type

interval

a character string consisting of zero or one digits (a count), an optional space, a word identifying the units to be grouped:sec, secs, min, mins, hour, hours, day, days, week, weeks. For example: "1 hour", "3 weeks" or "17 seconds".

Author

Greg Hunt <greg@firmansyah.com>

Examples

Run this code
d = as.POSIXct(c("2025-07-16 23:00:00", "2023-07-02 16:34:03", "2025-02-11 13:24:24"))
posixctCut(d, "17 mins")
posixctCut(d, "1 hour")
posixctCut(d, "1 week")

Run the code above in your browser using DataLab