Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 闪亮的悬停-奇怪的日期格式_R_Date_Shiny - Fatal编程技术网

R 闪亮的悬停-奇怪的日期格式

R 闪亮的悬停-奇怪的日期格式,r,date,shiny,R,Date,Shiny,我有一个闪亮的应用程序,它有一个时间序列图和一个悬停事件,该事件输出当前悬停值的日期和值。奇怪的是,它输出了一种我不能完全理解的日期格式。例如,2013-05-03变为1.369267e+12。有人能解释一下吗 下面是一个工作示例: ui.r shinyUI(fluidPage( sidebarLayout( position = "left", sidebarPanel( selectizeInput("fund", label = NULL, select

我有一个闪亮的应用程序,它有一个时间序列图和一个悬停事件,该事件输出当前悬停值的日期和值。奇怪的是,它输出了一种我不能完全理解的日期格式。例如,
2013-05-03
变为
1.369267e+12
。有人能解释一下吗

下面是一个工作示例:

ui.r

shinyUI(fluidPage(
  sidebarLayout(

    position = "left",

    sidebarPanel(
      selectizeInput("fund", label = NULL, selected = "", choices = c('', LETTERS[1:6]), options = list(placeholder = "Choose something"), width = "350px"),
      verbatimTextOutput("hover")
    ),

    mainPanel(
      plotlyOutput("tsplot")
    )


  )
))
require(shiny)
require(ggplot2)
require(plotly)

shinyServer(function(input, output) {

  PFobj <- reactive({

    pf <- input$fund
    ts_info <- list(a = "x", b = "y")
    ts_data <- data.frame(Dat = seq(Sys.Date() - 200, Sys.Date(), 1), Val = cumsum(c(100, rnorm(200))))

    list(pf = pf, nav = ts_info, data = ts_data)

  })

  observe({
    if(input$fund != '') {
      output$tsplot <- renderPlotly({
        p <- ggplot(PFobj()$data, aes(x = Dat, y = Val, group = 1, text = paste("</br>Date: ", Dat, "</br>Value: ", Val))) +
          geom_line(colour = "red")
        ggplotly(p, tooltip = c("text"))
      })
    }
  })

  output$hover <- renderPrint({
    d <- event_data("plotly_hover")
    if (!is.null(d)) {cat(d$x, d$y); b <<- d$x}
  })

})
server.r

shinyUI(fluidPage(
  sidebarLayout(

    position = "left",

    sidebarPanel(
      selectizeInput("fund", label = NULL, selected = "", choices = c('', LETTERS[1:6]), options = list(placeholder = "Choose something"), width = "350px"),
      verbatimTextOutput("hover")
    ),

    mainPanel(
      plotlyOutput("tsplot")
    )


  )
))
require(shiny)
require(ggplot2)
require(plotly)

shinyServer(function(input, output) {

  PFobj <- reactive({

    pf <- input$fund
    ts_info <- list(a = "x", b = "y")
    ts_data <- data.frame(Dat = seq(Sys.Date() - 200, Sys.Date(), 1), Val = cumsum(c(100, rnorm(200))))

    list(pf = pf, nav = ts_info, data = ts_data)

  })

  observe({
    if(input$fund != '') {
      output$tsplot <- renderPlotly({
        p <- ggplot(PFobj()$data, aes(x = Dat, y = Val, group = 1, text = paste("</br>Date: ", Dat, "</br>Value: ", Val))) +
          geom_line(colour = "red")
        ggplotly(p, tooltip = c("text"))
      })
    }
  })

  output$hover <- renderPrint({
    d <- event_data("plotly_hover")
    if (!is.null(d)) {cat(d$x, d$y); b <<- d$x}
  })

})
require(闪亮)
需要(ggplot2)
要求(详细地)
shinyServer(功能(输入、输出){

PFobjedit:经过一些研究,似乎输出的是图形位置的指针X轴值。尝试
print(d)
在您的
悬停
输出中。
d$x
d$y
为空。

编辑:经过一些研究,似乎输出是图形位置的指针x轴值。请尝试
打印(d)
在你的
hover
输出中。
d$x
d$y
是空的。

是否
逐字输出(“hover”)
字段也正确地输出了它?哈哈,哦,对了。我只是马上截屏,没有看到输出。是的,它被拧紧了。
逐字输出(“hover”)是我的错
字段输出也正确吗?哈哈,哦,对了。我只是马上截屏,没有看到输出。是的,它搞错了。我的错