Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用该 tidyquant包从 Alpha Vantage 创建一个数据集。我正在寻找一种解决方案来指定我的数据集的日期范围(似乎使用fromandto参数不起作用。
tidyquant
from
to
有什么建议么
我的代码如下
data <- c("EUR/USD", "EUR/ZAR") %>% tq_get(from = '2019-01-01',to = '2019-12-01',get = "alphavantage", av_fun = "FX_WEEKLY")
使用 Alphavantage 时不能设置from和选项。toAlphavantage 将返回前一百行数据或完整的可用数据集。但是 alphavantager 默认总是返回完整的数据集。获取数据后,您必须过滤起始日期和结束日期。
基本上,当您拥有数据时,请使用以下内容:
library(dplyr ) data %>% filter(between(timestamp, as.Date('2019-01-01'), as.Date('2019-12-01')))