找不到错误的圆形对象

时间:2015-04-20 12:28:01

标签: r shiny

我继续收到找不到的错误。有人可以解释为什么会这样吗?

我正在使用我复制到csv的数据(mtcars)数据集。我相信我已经修改了列名与csv中的完全相同。

错误

Error in eval(expr, envir, enclos) : object 'cyl' not found

Server.R

library(e1071)
library(caret)

data <- read.csv("./file/test.csv")
training <- data[-1,]

model <- svm(training$quality ~., data = training, probability=TRUE)


shinyServer(
  function(input, output) {

    dataInput <- reactive({  
        testing = data.frame("mpg"=input$mpg,"cyl"=input$cyl,"disp" = input$disp, 
        "dra t"=input$drat,"wt"=input$wt,
                            "qsec"=input$qsec, "vs"= input$vs, "am"= input$am,
                            "gear"=input$gear, "carb"=input$carb)
        #testing = testing[2,]
    })

    finalInput <- reactive({
      if (!input$adjust) return(dataInput())
      adjust(dataInput())
    })

    output$text1 <- renderText({ 
      paste("You have selected", input$am)
    })

    output$text2 <- renderText({ 
      paste("You have chosen a range that goes from",
            input$vs[1])
    })
    output$plot1 <- renderPlot({

      pred<- predict(model, testing, probability = TRUE)
      plot(pred)

      })

    output$text3 <- renderText({
      pred
      paste("the results are", pred)
    })

  }
)

UI.R

shinyUI(fluidPage(
  titlePanel("censusVis"),

  sidebarLayout(
    sidebarPanel(
      helpText("Create demographic maps with 
               information from the 2010 US Census."),

      selectInput("am", 
        label = "Choose a car type (1 for auto, 0 for manual)",
        choices = c("1", "0"),
        selected = "1"),

      selectInput("vs", 
                  label = "Choose a car vs ",
                  choices = c("1", "0"),
                  selected = "1"),

      sliderInput("mpg", 
        label = "mpg",
        min = 17, max = 40, value = 17, step = 0.1),

      sliderInput("cyl", 
                  label = "cyl",
                  min = 4, max = 8, value = 6, step = 1),

      sliderInput("disp", 
                  label = "disp",
                  min = 100, max = 305, value = 125),

      sliderInput("hp", 
                  label = "hp",
                  min = 90, max = 350, value = 117),

      sliderInput("wt", 
                  label = "wt",
                  min = 1.5, max = 5.5, value = 1.7, step = 0.3),

      sliderInput("qsec", 
                  label = "qsec",
                  min = 16, max = 21, value = 17, step = 0.1),

      sliderInput("gear", 
                  label = "gear",
                  min = 3, max = 5, value = 4, step = 1),

      sliderInput("carb", 
                  label = "carb",
                  min = 2, max = 6, value = 4, step = 1)


    ),

    mainPanel(
      textOutput("text1"),
      textOutput("text2"),
      textOutput("text3"),
      plotOutput("plot1")
    )
  )
))

0 个答案:

没有答案