0

I created a reactive object that I want to use in other parts of the app but it is not working there, it only works when I output it using "output$outputid" alone. For example; when I Pr2()$a in output$ex it worked but using Pr2()$b and Pr2()$c did not work in lm1 and I am so confused;

    Pr2 <- eventReactive(input$mspec,{
      if (is.null(input$mspec)) return()
      if (input$mspec==0) return() 
      if (input$msdata){
        df <- Pr()
      } else{
        df <- Dataset()
      }
      good2 <- data.frame(df)
      a <- data.frame(good2[,input$met2[1]:input$met2[2]])
      b <- t(a)
      c <- good2[,input$Prognostic]
      return(list(a=a,b=b,c=c))
    })

    output$ex <- renderPrint({
      print(Pr2()$c)
    })


    lm1 <-  reactive({
     if (is.null(input$mspec)) return()
      if (input$mspec==0) return()

      if (input$msdata){
          df2 <- Pr()
        } else{
          df2 <- Dataset()
        }
        if (is.null(df2)) return(NULL)
    isolate({
      Mdataa=Pr2()$b
      if (is.null(Mdataa)) return(NULL)
       MetabolicSurv::MSpecificCoxPh(reformulate(Survival=input$Survival,Censor=input$Censor,Reduce=input$Reduce,Select=input$num4,Quantile=input$num5,Prognostic=Pr2()$c,Mdata=Mdataa))
    })
      })
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. What exactly does "does not work" mean? What are you expecting? – MrFlick Feb 18 '19 at 17:00
  • Prognostic = Pr2()$c and Mdataa=Pr2()$b is not working as the error was that the arguments are not found but when i output Pr2()$c it produces the desire dataframe. So my question is how do you use the reactive objects Pr2()$b and Pr2()$c as argument in a function. – olajumoke owokotomo Feb 18 '19 at 17:05

0 Answers0