Je voudrais montrer un modalDialog si les utilisateurs oublient de télécharger un fichier d'étiquette. Cependant, mon modalDialog ne s'affiche jamais. Aucune suggestion? Merci!Comment afficher un message si un fichier n'est pas téléchargé dans R Shiny?
server.R:
function(input, output, session) {
# Read in labels
labels <- eventReactive (input$inFile2, {
ldata = read.csv(input$inFile2$datapath, header=input$header2)
return(ldata[, 1])
})
# Go to next tab only if labels are uploaded
observeEvent(input$act_next, {
if(nlevels(labels())> 0) {
updateTabsetPanel(session, "allResults", 'selVars')
} else {
#if(is.null(input$inFile2$size)) {
showModal(modalDialog(strong(h5("Please upload labels.")), easyClose = TRUE, footer = NULL))
#}
}
})
}
ui.R:
fluidPage(title = "Segmentation App", theme = shinytheme("spacelab"),
navbarPage("Segmentation", id = "allResults",
tabPanel(value ='inputData', title = 'Data Import',
verticalLayout(
h4("Import labels for the independent variables"),
fileInput(inputId="inFile2", "Choose a CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"
)
),
checkboxInput("header2", "Header", TRUE),
br(),
actionButton("act_next", strong("Next!"))
)
),
tabPanel(value ='selVars', title = 'Data Preparation',
verticalLayout(
)
)
) )
exemple d'un fichier CSV à charger: