Call Variable from reactive data() in R Shiny App

前端 未结 2 635
慢半拍i
慢半拍i 2021-01-12 19:31

I would like to call a certain variable within a reactive expression. Something like this:

server.R

library(raster)

shinyServer(fun         


        
2条回答
  •  爱一瞬间的悲伤
    2021-01-12 20:14

    Reactives are just like other functions in R. You can't do this:

    f <- function() {
      x <- 1
      y <- 2
    }
    
    f()$x
    

    So what you're within output$Plot() won't work either. You can do what you want by returning a list from data().

    data <- reactive({
    
      inFile <- input$test 
      asc <- raster(inFile$datapath) 
      list(asc_new1 = 1/asc, asc_new2 = asc * 100)
    
    }) 
    

    Now you can do:

    data()$asc_new1
    

提交回复
热议问题