Cannot get output variable from function call in server function


#1

I am doing this to print the list of pnames defined in the glycoPipe() function, but it does not work. What am I doing wrong?

ui <- fluidPage(
   CondtitionalPanel(
   condition = "output.pipe"
   textOutput("PIPE")

)

)


glycpPipe <- function(fileName){

pnames<- c("One", "Two", "Three", "Four")

list (pnames = pnames)



server <- function(input, output){
output$pipe <- reactive({
    result <- glycoPipe(inFileName)
    pipeLine <- result$pnames
    output$Pipe <- renderText({
      paste(pipeLine)
    })
   }**strong text**
    return(pipeLine)
  })

outputOptions(output,"pipe", suspendWhenHidden = FALSE)

#2

If I define the vector in the server function, the display works,

It seems to me that since rsult$pnames is a vector, I may have to use a way to extract the vector values from result$pnames for display. Is there any way to extract the values of a vector from a reactive function?

output$pipe <- reactive({
    #result <- glycoPipe(inFileName)
    pname <- c("One", "Two", "Three", "Four")
    #pipeLine <- result$merge_tol
    output$pipe <- renderText({
      paste("Attention ", pname)
    })
    
    return(pname)
  })
  outputOptions(output,"pipe", suspendWhenHidden = FALSE)

#3

When I try this little example, I get the error: " 1: runApp
Error in result$pname : $ operator is invalid for atomic vectors"

server <- function(input, output) {
  result <- glycoPipe(filename)
 
  value <- result$pname
  output$textbox <- renderText({

    
    value
  })
}

#4

I figured out that the function result <- glycoPipe(filename) was not returning any valeu because it was outside of the block where filename is defined. But now the error is;
Error in as.data.frame.default: cannot coerce class “c(“shiny.render.function”, “function”)” to a data.frame

({
  result <- glycoPipe(inFileName)
    #pname <- c("One", "Two", "Three", "Four")
    
    pipeLine <- result$pnames
    output$textBox <- renderText({
      paste("Attention ", pipeLine)
    })
    
  })

#5

Solved: This works:

({
 output$pipe <- reactive({
     
      result <- glycoPipe(inFileName)
      #pname <- c("One", "Two", "Three", "Four")
      
      pipeLine <- result$pnames
      output$textBox <- renderText({
        paste("Attention ", pipeLine)
      })
      
      return(pipeLine)
    })
    outputOptions(output, "pipe", suspendWhenHidden = FALSE)
    
  })