如何将selectInput与Shiny仪表板中的renderplot输出链接

时间:2019-05-06 13:54:59

标签: r shinydashboard

我正在尝试在selectInput中获得绘图输出,

ui:

selectInput("select", label = h3("Project Id"),
            choices=list("WP1"= "correlation", "WP2"=25 , "WP3"=6,"WP4", "adapt"),
            selected = 1),
             hr(),
      fluidRow(column(5, verbatimTextOutput("value"))

服务器:

output$value<-renderPlotly({input$select})

现在,我的情节是 ui:

fluidRow(
             column(6,plotlyOutput(outputId="timeseries", height="400px")),
             column(6,plotlyOutput(outputId="correlation", height="400px"))
                       )

服务器:

  # Read data
  stockdata <- read.csv("https://cdn.rawgit.com/plotly/datasets/master/stockdata.csv")

  # Create dates
  stockdata$Date <- as.Date(stockdata$Date)``

  # Reshape
  ds <- reshape2::melt(stockdata, id = "Date")
  ds <- filter(ds, variable != "GSPC")``

  # Set some colors
  plotcolor <- "#F5F1DA"``
 `` papercolor <- "#E3DFC8"``

  # Plot time series chart 
  output$timeseries <- renderPlotly({``
    p <- plot_ly(source = "source") %>% ``
      add_lines(data = ds, x = ~Date, y = ~value, color = ~variable, mode = "lines", line = list(width = 3))

我无法将WP1与该绘图输出链接。

0 个答案:

没有答案