【问题标题】:R Shiny Reactive plot using user selected variable使用用户选择的变量的 R Shiny Reactive 图
【发布时间】:2014-08-05 09:37:31
【问题描述】:

我最近开始使用 R-Shiny,但遇到了一个简单的问题,因此我被卡住了。

所以,我正在尝试构建一个反应式折线图,用户可以在其中定义数据库中的 2 个变量。

我已经能够获取下拉列表的变量列表,但我无法使用选定的值来绘制折线图。

参考代码:

library(shiny)

shinyUI(fluidPage(

# Application title
titlePanel("ARIMAX Forecasting Tool"),

sidebarLayout(
sidebarPanel(

...
mainPanel(
  tabsetPanel(type = "tabs", 
              tabPanel("Plot", plotOutput("plot")), 
              tabPanel("Summary")
  )
)
)
))

以及部分服务器代码

shinyServer(function(input, output) {
output$plot <- renderPlot({
inFile <- input$file1

if (is.null(inFile))
  return(NULL)

content1=read.csv(inFile$datapath, header=input$header, sep=input$sep 
)
h=input$x
k=input$ts

plot(content1$k,content1$h,type="l")
})
})

我已经跳过了编写渲染 UI 以让用户选择的部分 variables.xts 是用户为折线图选择的变量。

我在主面板区域出现错误:

需要有限的 xlim 值

【问题讨论】:

    标签: r shiny linechart shiny-server


    【解决方案1】:

    您必须包含一个可重现的示例 - 您的代码不会按原样运行。这适合我:

    shinyApp(ui=
      shinyUI(fluidPage(
        titlePanel("Title"),
        sidebarPanel(sliderInput("number_points",label = "Number of points",min = 10,max = 1000,value = 100)),
        mainPanel(
          plotOutput("plot")
        )
      )
    ),
    server=shinyServer(function(input, output) {
      output$plot <- renderPlot({
        plot(rnorm(input$number_points))
      })
    })
    )
    

    另外,检查读取文件的代码并在闪亮的应用程序之外显示绘图。确实,错误消息表明那里有问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-19
      • 1970-01-01
      • 1970-01-01
      • 2017-05-03
      • 2014-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多