我最近开始使用 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.x
,并且ts
是用户为折线图选择的变量。
我在主面板区域收到错误:
需要有限的 xlim 值