我每天都在处理按日期分组的数字范围数据,就像股票数据一样。使用 R Highcharter 股票图时,该图正确地获取了数据点/线的数值,但日期均列为 1970 年 1 月 1 日。
以前提出过这个问题:R HighCharter Stock Graph not correct pull dates but the method for working with the dates and successful uses the hc_add_series_time_values which is now deprecated in the Highcharter package。
给定 R 中的数据集:
date <- as.Date(c('2020-01-01','2020-01-02','2020-01-03', '2020-01-04', '2020-01-05'))
source <- c(21, 27, 38, 22, 33)
test <- data.frame(date, source)
我期望以下内容:
highchart(type = "stock") %>%
hc_add_series(test$source, type = "line")
生成带有 x 轴日期的股票图表。
我还查看了带有时间序列数据的 Highcharter plotBands、plotLines,认为日期列需要特殊的转换,但也没有产生预期的结果。
现在不推荐使用 highcharter stock 组件的时间值函数以使 x 轴接受日期时间值作为日期时间值,那么正确的过程是什么?