<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
本文于r format(Sys.Date(), "%Y-%m-%d")更新。 如发现问题或者有建议,欢迎提交 Issue
{r setup, include=FALSE} knitr::opts_chunk$set(eval = FALSE)
求滚动$\rho$[@tibbletime]
{r} set.seed(123) x <- rnorm(100) set.seed(456) y <- rnorm(100) x %>% head() y %>% head() t <- 1:100 t %>% head() test_roll_cor <- data_frame(x = x, y = y, t = t)
{r} rolling_cor <- rollify(.f = ~cor(.x,.y), window = 15)
{r} test_roll_cor %>% mutate(rolling_cor = rolling_cor(x,y))
as_tbl_time
{r} weather_time <- nycflights13::weather %>% select(origin, time_hour, temp, precip) %>% as_tbl_time(index = time_hour)
这里使用nycflights13::weather的数据,定义time index为time_hour。
{r} weather_time %>% head
collapse_by
{r eval=F} weather_time %>% group_by(origin) %>% collapse_by(period = "monthly")
tibbletime collapse_by Evaluation error: invalid 'tz' value. 但是会出现这个bug,已经向作者报错了, collapse_by error invalid timezone · Issue #51 · business-science/tibbletime
filter time[@Wang2018]
比原生的dplyr方便。 这里已经指定了time_hour为time index,因此直接给规则。
{r} weather_time %>% filter_time(~ "2013-01-02") %>% arrange(desc(time_hour))