2014-06-15 33 views
1

我最近開始使用R-Shiny,而且我有一個簡單的問題,因此我被卡住了。R使用用戶選擇變量的Shiny Reactive plot

所以,我試圖建立一個反應折線圖,其中用戶定義了數據庫中的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值

回答

0

你必須包括一個可重複例 - 你的代碼不能運行的是。這將運行對我來說:

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)) 
    }) 
}) 
) 

同時,檢查代碼讀取文件,並且顯示情節閃亮的應用程序之外的作品。事實上,錯誤信息表明在那裏出了問題。

相關問題