R使用用户选择的变量绘制反应性曲线图

R使用用户选择的变量绘制反应性曲线图,r,shiny,linechart,shiny-server,R,Shiny,Linechart,Shiny Server,我最近开始使用R-Shining,我有一个简单的问题,我被卡住了 因此,我试图构建一个反应式折线图,其中用户从数据库中定义了两个变量 我已经能够获得下拉列表中的变量列表,但无法使用所选值绘制折线图 请参阅代码: library(shiny) shinyUI(fluidPage( # Application title titlePanel("ARIMAX Forecasting Tool"), sidebarLayout( sidebarPanel( ... mainPanel( t

我最近开始使用R-Shining,我有一个简单的问题,我被卡住了

因此,我试图构建一个反应式折线图,其中用户从数据库中定义了两个变量

我已经能够获得下拉列表中的变量列表,但无法使用所选值绘制折线图

请参阅代码:

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")
})
})
shinyServer(功能(输入、输出){

输出$plot您必须包括一个可复制的示例-您的代码没有按原样运行。这对我来说是运行的:

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))
  })
})
)
shinyApp(用户界面)=
shinyUI(fluidPage)(
标题板(“标题”),
侧边栏面板(滑块输入(“点数”,标签=“点数”,最小值=10,最大值=1000,值=100)),
主面板(
绘图输出(“绘图”)
)
)
),
服务器=shinyServer(功能(输入、输出){
输出$plot