Learn R Programming

tsibble (version 0.1.0)

tsummarise: Aggregate over calendar periods

Description

It computes summary statistics for a tsibble over calendar periods, usually used in combination of group_by.

Usage

tsummarise(.data, ...)

tsummarize(.data, ...)

Arguments

.data

A data frame (of tbl_ts class).

...

Name-value pairs of expressions. The index variable must be present in the calls, coupled with an index function, to carry out the calculation. The index functions that can be used, but not limited:

Examples

Run this code
# NOT RUN {
# Monthly counts across Sensors
data(pedestrian)
monthly_ped <- pedestrian %>% 
  group_by(Sensor) %>% 
  tsummarise(
    Year_Month = yearmonth(Date_Time), # Year_Month will be the new index
    Max_Count = max(Count),
    Min_Count = min(Count)
  )
monthly_ped
index(monthly_ped)

# Annual trips by Region and State ----
data(tourism)
tourism %>% 
  group_by(Region | State) %>% 
  tsummarise(Year = lubridate::year(Quarter), Total = sum(Trips))
# }

Run the code above in your browser using DataLab