null - Global assignment within a reactive expression in R Shiny? -
suppose have data object uploaded user:
  data <- reactive({     infile <- input$file     if (is.null(infile)) return(null)     data <- read.csv(infile$datapath)     return(data)   })   and suppose want delete columns in dataset. want set global assignment can run ui multiple times , have each effect saved in object.
dataset <- reactive({     file1 <- data()     file1[,input$deletecols] <<- null     return(file1)    }} })   however, when run this, error:
invalid (null) left side of assignment
what's causing error? , how can achieve effect if global assignment doesn't work?
thanks much.
you should use reactivevalues() kind of need, because allows create , modify data @ different stages in app.
here example (not tested):
values <- reactivevalues()  observe({    infile <- input$file    if (!(is.null(infile))){      values$data <- read.csv(infile$datapath)    }  })  observe({   values$data[,input$deletecols] <- null })      
Comments
Post a Comment