Server function and function calls

Hello,

Suppose the following: in the server, inside a renderPrint component I will use shinijs::display("takeInput). This GUI component takes input from the user, so I will pass the input to a function by means of the function call. Afterwards, the function calls another function and sends the input to that function. The input will be received and tested by the second function. The result of the test will be returned to the first function which will return it to the server. Please see below:

Is there another way to do this? A simpler one? I would like to be able to use the second function program that takes in Input without modifications, but it seems that reaLines(prompt = ...) is not compatible with Shiny GUI display panel since readLines displays the question to take input in the terminal. I was wondering if there there is a way to display the readLines question in the GUI panel instead of in the terminal. A way of grabbing the reaLines function as it is and redirect its display from the terminal to the GUI panel

ui{
 selectInput("xxxxx")
verbatimTextOutput(
}

source(program containing functionName)
source(program containing another function name)

functionName <- function(parameters, takeInput){
functionName2 <-  anotherFunctionName(parameters, takeInput)
functionName2 <- valueOfFunctionName2
if(functionName2 == xx){
dosomthing 
return the value to the server
list(functionName2 = functionName2)
}


anotherFunctionName<- function(parameters, takeInput){

if(takeInput == something){
 return the value of anotherFunctionName to functionName which will return it to the server
 valueOfFunctionName2
}

}

}
serverFunction({

output$value <- renderPrint({
result <- functionName(parameters)
if(something == FALSE)
shinyjs::show(xxxxx)
})

output$takeInput<- renderPrint({
 takenInput <- input$xxxxx
result <- functionName(parameters, takeInput)
result$theValuereturnedby anotheFunctinName
})
1 Like

Sorry, I don't understand the question at all. Can you provide an example that's a little closer to running R code?

Here is an example that works. the GUI displays the selectInput box, the server renders selectInput Box and collects input, Collected input is sent to a function. This function sends the input to anther function. Something happens in the second function. The second function returns a function to the first function and the server function renders that value which is displayed by the GUI. I thought this is a very complex way to go about it and I was wondering it there was a Sniny compatible way to pick up the input directly from the first or second function.

Thanks

 ui <- fluidPage(

selectInput("Countparamsfile", label = h5(strong("Do you have a parameters file ready to use (Y/N)? ")),
                choices = c("", "Y", "N"),selected = NULL),
 verbatimTextOutput("CountparmsFile"),
selectInput("selectdatafiles",label = h5(strong("SELECT YOUR DATA FILE. To undo selection select the selected file again and press delete")),c(Choose='', list.files("~/Development/fileTest/GLYCOUNT/DATA")), multiple=TRUE, selectize=TRUE),
    verbatimTextOutput("selecteddatafiles"),
    verbatimTextOutput("inputTheFiles"),


)
server <- function(input, output, session{

output$glyCountparmsFile <- renderPrint({

                   shinyjs::show("Countparamsfile")
  })
 output$selecteddatafiles <- renderPrint({
                    result <- Counts()
                    filesOfData <- input$Countparamsfile
                    if(filesOfData == "Y" ){
                      shinyjs::show("selectdatafiles")
                    }
                    
                    if(filesOfData == "N"){
                      shinyjs::hide("selectdatafiles")
                    }
                    
                })
                
               output$inputTheFiles <- renderPrint({
                 fOfData <- unlist(input$selectdatafiles)
                 
                 if(!is.null(fOfData)){
                 result <- Counts(fOfData)
                 receivedvalue <- paste(result$dataFnd, dataFnsDir
                  receivedValue

                 }
             })
}

function <- Counts(inFileName, fOfData = NULL){
if(!is.null(fOfData)){
fileChoice = fOfData

        }

List[dataFns, dataFnsDir] <- Counts2(fileChoice = fileChoice)

list(dataFns = dataFns, dataFnsDir = dataFnsDir)
}

function <- Counts2(fileChoice = NULL){
fileChosen = NULL

    fileValue = FALSE
    if(!is.null(fileChoice)){
      fileChosen = fileChoice
      dataFns <- fileChoice
      dataFns<- sort(unique(dataFns))
      dataFnsDir<- dirname(dataFns[1])
    }

#Value to return to the call to Counts function() made from Counts() function
list(dataFns= dataFns, dataFnsDir = dataFnsDir)
}
}