| format_interval {padr} | R Documentation | 
Make a period character vector
Description
After applying thicken all the observations of a period are mapped
to a single time point. This function will convert a datetime variable to
a character vector that reflects the period, instead of a single time point.
strftime is used to format the start and the end of the interval.
Usage
format_interval(
  x,
  start_format = "%Y-%m-%d",
  end_format = start_format,
  sep = " ",
  end_offset = 0,
  units_to_last = NULL
)
Arguments
| x | A vector of class  | 
| start_format | String to format the start values of each period, to be used
in  | 
| end_format | String to format the end values of each period, to be used
in  | 
| sep | Character string that separates the  | 
| end_offset | Units in days if  | 
| units_to_last | To determine the formatting of the last value in  | 
Details
The end of the periods will be determined by the next unique value
in x. It does so without regarding the interval of x. If a specific
interval is desired, thicken and / or pad should first be
applied to create an equally spaced datetime variable.
Value
A character vector showing the interval.
Examples
library(dplyr)
library(ggplot2)
plot_set <- emergency %>%
  head(500) %>%
  thicken("hour", "h") %>%
  count(h)
# this will show the data on the full hour
ggplot(plot_set, aes(h, n)) + geom_col()
# adding a character to indicate the hours of the interval.
plot_set %>%
  mutate(h_int = format_interval(h, "%H", sep = "-"))