反应对象:无效(NULL)左侧的分配错误与闪亮的应用程序

时间:2017-12-29 19:21:05

标签: r shiny

我是使用R闪亮的新手。 我想在删除缺失值后显示上传的数据集。 但即使代码在没有使用Shiny app的情况下运行良好,我也无法理解错误。

这是我的R代码:

ui <- fluidPage(
tabItem(tabName = "summary" ,
        tabsetPanel(tabPanel("Data", dataTableOutput("data")))
       )
)

server <- function(input, output) {
 ### Argument names:
  ArgNames <- reactive({
  Names <- names(formals(input$readFunction)[-1])
  Names <- Names[Names!="..."]
  return(Names)
})

# Argument selector:
output$ArgSelect <- renderUI({
if (length(ArgNames())==0) return(NULL)
selectInput("arg","Argument:",ArgNames())
})

 ## Arg text field:
 output$ArgText <- renderUI({
 fun__arg <- paste0(input$readFunction,"__",input$arg)

 if (is.null(input$arg)) return(NULL)

 Defaults <- formals(input$readFunction)

 if (is.null(input[[fun__arg]]))
 {
  textInput(fun__arg, label = "Enter value:", value = 
  deparse(Defaults[[input$arg]])) 
  } else {
  textInput(fun__arg, label = "Enter value:", value = input[[fun__arg]]) 
 }
})

### Data import:
Dataset <- reactive({
if (is.null(input$file)) {
  # User has not uploaded a file yet
  return(data.frame())
 }

args <- grep(paste0("^",input$readFunction,"__"), names(input), value = 
TRUE)

argList <- list()
for (i in seq_along(args))
{
  argList[[i]] <- eval(parse(text=input[[args[i]]]))
}
names(argList) <- gsub(paste0("^",input$readFunction,"__"),"",args)

argList <- argList[names(argList) %in% ArgNames()]

 Dataset <-as.data.frame (do.call(input$readFunction,
      c(list(input$file$datapath),argList)))
return(Dataset)
})

 # Show data:
 output$data <- renderDataTable({
 for(i in 1:ncol( Dataset())){
  Dataset()[is.na( Dataset()[,i]), i] <- mean( Dataset()[,i], na.rm = TRUE)
 }
 })

}

shinyApp(ui, server)

当运行代码时,我收到此错误:

invalid (null) left side of assignment shiny

有人可以帮我解决问题吗?

0 个答案:

没有答案