r - R:function_list [[k]](值)中的错误:找不到函数“dyCandlestick”
问题描述
我正在尝试使用 R 的 dygraphs 包绘制历史外汇数据 - 使用 dyCandlestick 函数。出于某种原因,即使加载了 dygraphs 包,R 也没有找到 dyCandlestick 函数。
我已经成功运行了这段代码,但是我在下面显示的内容中添加了一些新行,现在它无法正常工作。我知道 tidyverse 与 xts 和 lubridate 的某些功能发生冲突,但无论如何我不明白该怎么做。
# historical Forex data obtained from:
#https://www.dukascopy.com/swiss/english/marketwatch/historical/
library(xts) # To make the convertion data-frame / xts format
library(lubridate)
library(dygraphs)
library(tidyverse)
raw_data <- read.csv("EURUSD_Candlestick_1_Hour_BID_01.01.2018-07.09.2019.csv") #data frame
i <- 1
time <- vector(length = nrow(raw_data))
for (when in raw_data$Local.time){
dtz <- strsplit(when, " ") #split date, time and GMT
when <- paste(dtz[[1]][1], dtz[[1]][2]) #use only date and time
datetime <- as.POSIXct(when, format = "%d.%m.%Y %H:%M:%OS")
time[i] <- strftime(datetime, "%d-%m-%Y %H:%M:%OS")
i<-i+1
}
#replace data with the new format
raw_data$Local.time <- NULL
raw_data$Local.time <- dmy_hms(time)
raw_data <- raw_data[c(1:77), ]
x = data.frame(raw_data$Open, raw_data$High, raw_data$Low, raw_data$Close)
#Candlestick charts use the first four data series to plot, the rest of the data series (if any) are rendered with line plotter
final_data <- xts(x = x, order.by = raw_data$Local.time)
dygraph(final_data) %>% dyCandlestick() #%>% dyOptions(sigFigs=5)
一旦我运行最后一行,我就会收到此错误消息: function_list [k] 中的错误:找不到函数“dyCandlestick”
任何帮助,将不胜感激!此外,非常感谢对本可以做得更好的代码的其他部分的评论 - 我对 R 有点陌生 :)
解决方案
推荐阅读
- python - 如何通过使用 itemgetter 的列表值对字典进行排序?
- python - 如何从我的列表和python中的元组中删除空白引号?
- xamarin - Azure Devops 构建失败:未找到具有提供的指纹的证书
- javascript - 我如何在不和谐 v12 中列出角色中的所有成员?
- python - cadytsiterate.py 的输入是什么?
- dataframe - 如何过滤朱莉娅数据框?
- kotlin - 如何找到默认的 kotlin 编译器参数值?
- r - R语言定义:使用美元符号索引命名向量
- python - 通过操作 pyvenv.cfg 部署烧瓶,包括创建的 venv
- java - 尝试运行 jar 文件时出现 java.lang.UnsatisfiedLinkError