r - Filter_time 函数 - 在 R 中过滤时间
问题描述
我正在尝试根据 R Bloggers 的这个博客进行一些时间序列预测。 使用 keras 进行时间序列预测
这是我正在尝试使用的代码。
# Core Tidyverse
library(tidyverse)
library(glue)
library(forcats)
library(dplyr)
# Time Series
library(timetk)
library(tidyquant)
library(tibbletime)
library(stats)
# Visualization
library(cowplot)
# Preprocessing
library(recipes)
# Sampling / Accuracy
library(rsample)
library(yardstick)
# Modeling
library(keras)
library(tfruns)
#reading excel file
library("readxl")
incoming_volume <- read_excel(file.choose())
volume <- incoming_volume %>%
tk_tbl() %>%
mutate(index = as_date(index)) %>%
as_time(index = index)
p1 <- volume %>%
ggplot(aes(index, value)) +
geom_point(color = palette_light()[[1]], alpha = 0.5) +
theme_tq() +
labs(
title = "From July 2011 to May 2018 "
)
p2 <- volume %>%
filter_time("start" ~ "2011") %>%
ggplot(aes(index, value)) +
geom_line(color = palette_light()[[1]], alpha = 0.5) +su
geom_point(color = palette_light()[[1]]) +
geom_smooth(method = "loess", span = 0.2, se = FALSE) +
theme_tq() +
labs(
title = "2011 to 2018 (Zoomed In To Show Changes over the Year)",
caption = "Incoming Volume"
)
我收到一条错误消息,指出找不到 filter_time 函数。我也试过 time_filter 。我遇到了同样的错误。
我怎么能避免这个错误。
问候,任。
解决方案
您可以通过以下方式更改“filter_time”:
require(lubridate)
p2 <- volume %>%
filter(year(as.Date(index)) > 2011)
推荐阅读
- node.js - Facebook Ads API 已弃用,请更新至最新版本 v3.0
- node.js - 如何从nodejs Google Tasks API中的任务列表中获取具有截止日期的任务?
- symfony - 具有由 3 个字段组成的组合主键的单个表上的教义映射
- swift - 我们可以检测何时找不到动态图像文字吗?
- azure - 每次重新启动时 Azure 应用服务都会中断
- firebase - 如何在 Flutter 的 firebase_database 中执行事务?
- javascript - Ajax 响应在检查器中正常,在 jquery 中不起作用
- ios - 我怎样才能快速执行关系?
- mysql - 获取在值范围内具有值的行数 MySQL
- vba - 点击表格单元格生成图表