Hello,
How can i display the GUI component below in a loop for 1:30. What I have written does not work.
Thanks
output$combiningFiles <- renderPrint({
result <- glycoPipe(inFileName())
combined <- result$comb
if(combined == FALSE){
for(i in 1: 30){
shinyjs::show("combinefiles")
}
}
})
I found this solution, but now I need to send the input to a function as many times as there is input. How could I do that? Please see below. The code below takes in the input and sends it to the glycoPipe function only once. Thanks.
ui <- fluidPage(
actionButton("add", "Select files to combine")
)
observeEvent(input$add, {
if(input$combinefiles == "Y"){
insertUI(
selector = "#add",
where = "afterEnd",
#ui = textInput(paste0("txt", input$add),
# "Insert some text")
selectInput("filescombine",label = h5(strong("PLEASE CHOSE FILES TO COMBINE. To undo selection select the selected file again and press delete")),c(Choose='', list.files("~/Development/fileTest/GLYCOUNT/DATA")), multiple=TRUE, selectize=TRUE)
)
output$combining <- renderPrint({
selections <- unlist(input$filescombine)
result <- glycoPipe(inFileName(), xValue = NULL, xxValue = NULL, xxxValue = NULL, xxxxValue = NULL, xxxxxValue = NULL, input$selectYN, V = NULL, other = NULL, largeTable = NULL, LSelection = NULL, glycoFile = NULL, filesValue = NULL, indexNumber = NULL, question = NULL, MMF = NULL, userA= NULL, input$glyCountparamsfile, fOfData = NULL, combineResult = NULL, unlist(input$filescombine))
selections
})
}
})
I was able to count the number of times the user presses the button and that will capture the total number of sets selected, but I cannot count the number of files selected every time the button is pressed and the files are displayed. What I have done does not work.
observeEvent(input$add,{
isolate({
numberOfItems$selections <- unlist(input$filescombine)
})
})
Please see this part in the program below.
library(shiny)
# Define UI
ui <- fluidPage(
actionButton("add", "Add UI"),
textOutput("count")
# Server logic
server <- function(input, output, session) {
counter <- reactiveValues(countervalue = 0)
numberOfItems <- reactiveValues(selections = NULL)
observeEvent(input$add,{
isolate({
counter$countervalue <- counter$countervalue + 1
})
insertUI(
selector = "#add",
where = "afterEnd",
selectInput("filescombine",label = h5(strong("PLEASE CHOSE FILES TO COMBINE. To undo selection select the selected file again and press delete")),c(Choose='', list.files("~/Development/fileTest/GLYCOUNT/DATA")), multiple=TRUE, selectize=TRUE)
# selections <- unlist(input$filescombine)
)
})
observeEvent(input$add,{
isolate({
numberOfItems$selections <- unlist(input$filescombine)
})
})
output$count <- renderText({
paste(counter$countervalue, numberOfItems$selections)# print the latest value stored in the reactiveValues object
})
}
# Complete app with UI and server components
shinyApp(ui, server)
What I have realized running this program below is that only one isolate({value = ....}) is associated with the button. So maybe, that is why numberOfItemSelections is not in the output.
library(shiny)
# Define UI
ui <- fluidPage(
actionButton("add", "Add UI"),
textOutput("count")
)
# Server logic
server <- function(input, output, session) {
counter <- reactiveValues(countervalue = 0)
counter2 <- reactiveValues(countervalue2 = 0)
numberOfItems <- reactiveValues(selections = NULL)
observeEvent(input$add,{
isolate({
counter$countervalue <- counter$countervalue + 1
})
isolate({
numberOfItems$selections <- unlist(input$filescombine)
})
isolate({
counter2$countervalue2<- counter$countervalue2 + 1
})
insertUI(
selectInput("filescombine",label = h5(strong("PLEASE CHOSE FILES TO COMBINE. To undo selection select the selected file again and press delete")),c(Choose='', list.files("~/Development/fileTest/GLYCOUNT/DATA")), multiple=TRUE, selectize=TRUE),
selector = "#add",
where = "afterEnd",
numberOfItems$selections <- input$filescombine
)
})
output$count <- renderText({
paste(counter$countervalue, counter2$countervalue2, numberOfItems$selections)# print the latest value stored in the reactiveValues object
})
}
# Complete app with UI and server components
shinyApp(ui, server)