floor_time: Floor a datetime column to a calendar grid

View source: R/resample.R

floor_timeR Documentation

Floor a datetime column to a calendar grid

Description

Truncates a Date or POSIXct column down to a unit boundary – the basis for time bucketing. Usable inside mutate() / filter(); resample() calls it for you.

Usage

floor_time(t, unit)

Arguments

t

A Date or POSIXct column (stored as days / seconds since the epoch).

unit

A bucket size as a string: a count and a unit, e.g. "hour", "15 min", "day", "week", "3 months", "quarter", "year".

Details

The result is returned in the column's own scale (days for Date, seconds for POSIXct), so it remains a valid instant. The engine does not re-attach the Date/POSIXct class to a computed column, so a floored column collects as the underlying numeric epoch; wrap with as.POSIXct(x, origin = "1970-01-01", tz = "UTC") or as.Date(x, origin = "1970-01-01") if you need the class back.

Value

A numeric (epoch) column.

See Also

resample()


vectra documentation built on July 10, 2026, 5:08 p.m.