R shiny 对象找不到

代码如下:


server <- function(input, output,session) {
  
randomVals <- eventReactive(input$go,
    { 
      if (input$data_type == "upload" & (!is.null(input$File_to_plot))) {
        data_table <- read.csv(input$File_to_plot$datapath)
      } else if (input$data_type == "example") {
        data_table <- read.csv(paste0(service_APP,"example_data.csv"))
      } 
      output$data_view1 <-renderDataTable({
      datatable(data_table)})

    if (input$method == "over") {
    data_balanced <-ovun.sample(cls ~ ., data=data_table,p=0.5,seed=1, method ="over")$data}
    else if (input$method == "under") {
    data_balanced <-ovun.sample(cls ~ ., data=data_table,p=0.5,seed=1, method ="under")$data}
   else if (input$method == "both") {
    data_balanced <-ovun.sample(cls ~ ., data=data_table, N = nrow(data_table),p=0.5,seed=1,method ="both")$data}

      output$data_view2 <-renderDataTable({
      datatable(data_balanced)})
    })


img

我应该怎么操作才能运行成功

在server函数的开头定义data_table变量再看看