R 使用x轴作为日期打印笔刷限制
我试图复制rstudio页面上提供的这个示例 问题是,我需要在x轴上使用日期(R 使用x轴作为日期打印笔刷限制,r,ggplot2,shiny,R,Ggplot2,Shiny,我试图复制rstudio页面上提供的这个示例 问题是,我需要在x轴上使用日期(as.date%d/%m/%Y),在绘图上缩放时会出现此错误 无效输入:date_trans仅适用于类date的对象 库(ggplot2) 图书馆(比例尺) 图书馆(网格) 图书馆(DT) ui您好您需要将范围2$x转换为最新版本: output$plot2 <- renderPlot({ if (!is.null(ranges2$x)) { ranges2$x <- as.Date(rang
as.date%d/%m/%Y
),在绘图上缩放时会出现此错误
无效输入:date_trans仅适用于类date的对象
库(ggplot2)
图书馆(比例尺)
图书馆(网格)
图书馆(DT)
ui您好您需要将范围2$x
转换为最新版本:
output$plot2 <- renderPlot({
if (!is.null(ranges2$x)) {
ranges2$x <- as.Date(ranges2$x, origin = "1970-01-01")
}
ggplot(articles, aes(Date, Sevdow)) +
geom_point() +
coord_cartesian(xlim = ranges2$x, ylim = ranges2$y)
})
@维克多克普。谢谢你的意见。我真的很感激。
output$plot2 <- renderPlot({
if (!is.null(ranges2$x)) {
ranges2$x <- as.Date(ranges2$x, origin = "1970-01-01")
}
ggplot(articles, aes(Date, Sevdow)) +
geom_point() +
coord_cartesian(xlim = ranges2$x, ylim = ranges2$y)
})
output$selected_rows <- renderDataTable({
articles$Date <- as.numeric(articles$Date)
nearPoints(articles, coordinfo = input$plot_click, xvar = "Date", yvar = "Sevdow",
threshold = 10, maxpoints = 1000,
addDist = FALSE, allRows = FALSE)
})