What am I doing wrong?
This is the function that is being called from the function external to the Gui and to the Server and which is in an file called utilities.R in the Utilities folder. I use source() to import the script.
checkParams <- function(PARAMSfullFile = NULL){
pass <- TRUE
return(pass)
}
ui <- fluidPage(
sidebarLayout(
mainPanel(
#tableOutput("contents")
textOutput("textbox")
)
)
)
glycoPipe <- function(PARAMSfullFile) {
pass <- glycoPipe(PARAMSfullFile)
list(pass = pass)
}
server <- function(input, output) {
source("Utilities/utilities.R", chdir = TRUE)
output$contents <- renderTable({
if(input$btn){
hide("btn")
}
inFile = input$file
inFileName = input$file$name
if(is.null("inFile")){
return()
}
req(inFile)
validate( need(file_ext(inFile) %in% c(
'tsv'
), "Wrong File Format. The selected file is not a valid tab-separated PARAMS file try again. If
you do not have a parameters.tsv file in your directory stop clycoPipe create a file and re-start glycoPipe"))
read.delim(inFile$datapath, quote = "", sep = '\t')
result <- glycoPipe(inFileName)
#start_time_text <- strftime(result$start_time, "%H:%M:%S")
value <- result$pass
#value <- result$as.list(pname)
output$textbox <- renderText({
value
})
})
}
shinyApp(ui = ui, server = server)
What about it is not working? It is hard for us to help debug your code when you don't give a detailed description of the problem you are facing.
I got it to work now. I mean by that that the output returned by the function "CheckParams(inFileName) gets printed when "pass == TRUE" and does not get printed when "pass == FALSE". Thank you for your reply.
library(shiny)
library(gsubfn)
ui <- fluidPage(
sidebarLayout(
sidebarpanel(
)
)
),
mainPanel(
conditionalPanel(
condition = "output.checkedParameters == 'true",
textOutput("checkedInput"),
)
)
)
externalFunction <- function(inputFile){
list[params, pass] <- checkParams(PARAMSfullFile)
if(is.null(pass)) return()
}
checkParams <- function(inputFile){
params = "params"
pass = TRUE
return(list(pass, paramas))
}
server <- function(input, output){
output$checkedParameters <- reactive({
inFile = input$file
inFileName = input$file$name
result <- glycoPipe(inFileName)
returnedParam1 <- result$params
returnedParam2 <- result$pass
if(returnedParam2 == TRUE){
output$checkedInput <- renderText({
paste(returnedParam1, returnedParam2)
})
}
return(paste(returnedParam1, returnedParam2))
})
outputOptions(output, "checkedParameters", suspendWhenHidden = FALSE)
}
The conditional panel does not work becuase the helpText is not displayed, and the value of pass is not returned. The textOutput("....") is not displayed in the conditional panel. Things stopped working when I added the second conditinal panel which displays the value returned by another function.
ui <- fluidPanel(
sidebarLayout(
sidebarPanel()
mainPanel(
conditionalPanel(
condition = "output.checkedParameters",
textOutput("checkedInput"),
helpText("\n\n###############################################################\n"),
helpText("######### GLYCOPIPE GLYCOSYLATION ANALYSIS SOFTWARE ##########\n
###############################################################\n")
)
# conditionalPanel(
# condition = "output.returnedResponse",
# textOutput("returnedResp")
#)
)
)
)
server <- function(input, output){
output$checkedParameters <- reactive({
inFile = input$file
inFileName = input$file$name
result <- glycoPipe(inFileName)
returnedParam1 <- result$params
returnedParam2 <- result$pass
if(returnedParam2 == TRUE){
output$checkedInput <- renderText({
paste(returnedParam1, returnedParam2)
})
}
return(paste(returnedParam1, returnedParam2))
})
outputOptions(output, "checkedParameters", suspendWhenHidden = FALSE)
}