gpt4 book ai didi

r - asJSON(keep_vec_names=TRUE) 的输入是一个命名向量。在未来的 jsonlite 版本中,将不支持此选项

转载 作者:行者123 更新时间:2023-12-05 07:35:28 25 4
gpt4 key购买 nike

请在下面找到一个可重现的示例来解释我的问题(我正在使用与 Shiny R 包直接相关的 manipulateWidget R 包):

library(ggplot2)
library(plotly)
library(manipulateWidget)
library(data.table)


my_data <- data.table(
DAT_RLV = as.POSIXct(c("2017-01-20","2017-01-21","2017-01-22",
"2017-01-23","2017-01-24")),
VOL_CSO = c(0,4,3,4,2))


graphe_conso <- ggplot(data = my_data)+
geom_line(aes(x = DAT_RLV,y = VOL_CSO),colour = "darkgreen")+
labs(x = "Date", y ="my_values")

graphe_conso <- ggplotly(graphe_conso)

目前,一切都很好。这是我得到的:

enter image description here

然后我想将这个图表用作 Shiny 对象:

manipulateWidget::combineWidgets(graphe_conso)

我的 x 轴上的所有日期都已转换为另一种格式,我收到以下警告:

enter image description here

这是我在 x 轴上得到的:

enter image description here

任何提示都可以解决这个问题,非常感谢!

最佳答案

当将 POSIXct 列转换为数字并乘以 1000 时,它显然得到了解决。然后在 ggplotly 命令中,您必须指定 x 轴的类型为“date”。

然后它看起来是正确的,Input to asJSON(keep_vec_names=TRUE)-错误消失了。但我实际上并不知道确切的原因。 Date/POSIXct 列显然存在一些错误。

library(ggplot2)
library(plotly)
library(manipulateWidget)
library(data.table)

my_data <- data.table(
DAT_RLV = as.POSIXct(c("2017-01-20","2017-01-21","2017-01-22",
"2017-01-23","2017-01-24")),
VOL_CSO = c(0,4,3,4,2))

my_data$DAT_RLV <- as.numeric(my_data$DAT_RLV)*1000
graphe_conso <- ggplot(data=my_data)+
geom_line(aes(x = DAT_RLV, y = VOL_CSO, group = 1))+
labs(x = "Date", y ="my_values")
graphe_conso <- ggplotly(graphe_conso) %>%
layout(xaxis = list(type = "date"))
manipulateWidget::combineWidgets(graphe_conso)

关于r - asJSON(keep_vec_names=TRUE) 的输入是一个命名向量。在未来的 jsonlite 版本中,将不支持此选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49534610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com