将SliderValue应用于输入的文件

将SliderValue应用于输入的文件,r,shiny,R,Shiny,我正在尝试将我的应用程序中的滑块值连接到从上传的文件渲染的表,尽管我不知道如何正确地进行连接。下面是代码现在的样子: 服务器.r library(shiny) function(input, output) { # upload the csv file output$contents <- renderTable({ inputFile <- input$file1 if (is.null(inputFile)) return(NULL

我正在尝试将我的应用程序中的滑块值连接到从上传的文件渲染的表,尽管我不知道如何正确地进行连接。下面是代码现在的样子:

服务器.r

library(shiny)

function(input, output) {

  # upload the csv file

  output$contents <- renderTable({

    inputFile <- input$file1

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

    read.csv(inputFile$datapath, header=input$header, sep=',',
             quote="'")
  })

  # Create a frame with our values

  sliderValues <- reactive({

    # Compose data frame
    data.frame(
      Name = c("cost", 
               "range"),
               Value = as.character(c(input$cost, 
                                      paste(input$range, collapse=' ')
               ), 
               stringsAsFactors=FALSE)
    )
  }) 

  # Show the values
  output$values <- renderTable({
    sliderValues()
  })
}
最后,我用来测试它的文件如下所示:

Car, Horsepower, MaxSpeed, Cost
AlfaRomeo, 200, 300, 200000
AstonMartin, 400, 310, 300000

差不多完成了。只需使用
输入值分配
数据帧
子集

mytable<-read.csv(inputFile$datapath, header=input$header, sep=',',
         quote="'")

subset(mytable,mytable$Cost<input$cost & mytable$MaxSpeed>=input$range[1] & mytable$MaxSpeed<=input$range[2] )

MyTable谢谢!正是我想要的。我不知道
子集
,今天是我学习的第一天。
mytable<-read.csv(inputFile$datapath, header=input$header, sep=',',
         quote="'")

subset(mytable,mytable$Cost<input$cost & mytable$MaxSpeed>=input$range[1] & mytable$MaxSpeed<=input$range[2] )