tsibble-tidyverse | R Documentation |
Current dplyr verbs that tsibble has support for:
dplyr::filter()
, dplyr::slice()
, dplyr::arrange()
dplyr::select()
, dplyr::transmute()
, dplyr::mutate()
, dplyr::relocate()
,
dplyr::summarise()
, dplyr::group_by()
dplyr::left_join()
, dplyr::right_join()
, dplyr::full_join()
,
dplyr::inner_join()
, dplyr::semi_join()
, dplyr::anti_join()
,
dplyr::nest_join()
dplyr::bind_rows()
, dplyr::bind_cols()
Current tidyr verbs that tsibble has support for:
tidyr::pivot_longer()
, tidyr::pivot_wider()
,
tidyr::gather()
, tidyr::spread()
tidyr::nest()
, tidyr::fill()
, tidyr::drop_na()
The index variable cannot be dropped for a tsibble object.
When any key variable is modified, a check on the validity of the resulting tsibble will be performed internally.
Use as_tibble()
to convert tsibble to a general data frame.
A warning is likely to be issued, if observations are not arranged in past-to-future order.
Joining with other data sources triggers the check on the validity of the resulting tsibble.
library(dplyr, warn.conflicts = FALSE)
# `summarise()` a tsibble always aggregates over time
# Sum over sensors
pedestrian %>%
index_by() %>%
summarise(Total = sum(Count))
# shortcut
pedestrian %>%
summarise(Total = sum(Count))
# Back to tibble
pedestrian %>%
as_tibble() %>%
summarise(Total = sum(Count))
library(tidyr)
stocks <- tsibble(
time = as.Date("2009-01-01") + 0:9,
X = rnorm(10, 0, 1),
Y = rnorm(10, 0, 2),
Z = rnorm(10, 0, 4)
)
(stocksm <- stocks %>%
pivot_longer(-time, names_to = "stock", values_to = "price"))
stocksm %>%
pivot_wider(names_from = stock, values_from = price)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.