【问题标题】:Error:origin must be supplied How to solve this?错误:必须提供原点如何解决?
【发布时间】:2018-12-01 20:35:57
【问题描述】:
date=seq(as.Date('2000-1-3'),length.out=6486,by=1)

library(shiny)
ui <- basicPage(
  plotOutput("zoom", height = "350px"),
  plotOutput("overall", height = "150px",
             brush =  brushOpts(id = "brush", direction = "x")
  )
)

server <- function(input, output){
  data=data.frame(
    date=date,
    ucl2=ucl2,
    ucl1=ucl1,
    price=price,
    lcl1=lcl1,
    lcl2=lcl2
  ) 


  p <- ggplot(data,aes(x=date))+
    geom_line(aes(y=ucl2),colour="blue")+
    geom_line(aes(y=lcl2),colour="blue")+
    geom_line(aes(y=price),colour="red")+
    geom_line(aes(y=ucl1),colour="green")+
    geom_line(aes(y=lcl1),colour="green")+
    ggtitle("7 days") + 
    xlab("ma of 7 days") +
    ylab("standard deviation")


  output$zoom <- renderPlot({
    if (!is.null(input$brush)) {
      p <- p +xlim(input$brush$xmin, input$brush$xmax)
    }
    p
  })

  output$overall <- renderPlot(p)
}

shinyApp(ui, server)
Warning: Error in as.Date.numeric: 'origin' must be supplied

我已经通过这些命令以闪亮的方式获得了我想要的图形,但放大功能不起作用,当我选择要放大的数据时,它会显示错误。 错误:必须提供原点 这个问题怎么解决??

【问题讨论】:

  • 什么是x = date。你的意思是x = Date.Time
  • date=seq(as.Date('2000-1-3'),length.out=6486,by=1) @MichaelChirico x=date

标签: r date shiny rstudio


【解决方案1】:

试试这个:

  output$zoom <- renderPlot({
    if (!is.null(input$brush)) {
      p <- p + xlim(as.Date("1970-01-01") + input$brush$xmin, as.Date("1970-01-01") + input$brush$xmax)
    }
    p
  })

【讨论】:

  • 感谢它有效,但每当我放大时它都会显示此错误警告:删除了包含缺失值 (geom_path) 的 6129 行。警告:删除了 6129 行包含缺失值 (geom_path)。警告:删除了 6129 行包含缺失值 (geom_path)。警告:删除了 4986 行包含缺失值 (geom_path)。警告:删除了 4986 行包含缺失值 (geom_path)。警告:删除 4986 行包含缺失值 (geom_path)。
  • 这不是错误,是警告,结果正确吗?
猜你喜欢
  • 1970-01-01
  • 2023-03-22
  • 2019-11-17
  • 1970-01-01
  • 1970-01-01
  • 2011-02-17
  • 1970-01-01
  • 2020-02-20
  • 2020-05-03
相关资源
最近更新 更多