0
ユーザーがラベルファイルを忘れた場合は、modalDialogを表示したいと思います。しかし、私のmodalDialogは決して現れません。助言がありますか?ありがとう!ファイルが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:負荷にCSVファイルの
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(
)
)
) )
例: