0

I am new in using R shiny. I am trying to display an uploaded dataset after removing missing values. But I can not understand the error even if the code runs well without using Shiny app.

here is my R code :

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)

When runnig the code I get this error :

invalid (null) left side of assignment shiny

Can anyone help me to solve the problem please ?

Karima Touati
  • 37
  • 2
  • 7
  • 1
    Where is `Dataset()` coming from? Please make sure you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) when asking for help. – MrFlick Dec 29 '17 at 19:34
  • @MrFlick I edited my code – Karima Touati Dec 29 '17 at 19:48

0 Answers0