I am trying to make a flex dashboard app with a picker input with a associated switch:
#Select clustering method
pickerInput(
inputId = "Cluster_method",
label= h4("Clustering Method"),
choices = c("KMeans", "DBscan"),
selected = "DBscan",
multiple = FALSE,
options= pickerOptions(
actionsBox = FALSE,
selectedTextFormat = "count > 2",
size = 10
)
)
switch(observeEvent(input$Cluster_method, "DBscan"),
"Kmeans" = numericInput(
inputId = "n_clusters",
label= h4("Number of clusters"),
value = 3,
min = 1,
max= 10
),
"DBscan"={
numericInput(
inputId = "n_radius",
label= h4("Search radius"),
value = 3,
min = 1,
max= 500
)
numericInput(
inputId = "n_minpoints",
label= h4("Min points"),
value = 3,
min = 1,
max= 100
)
}
)
This will lead to the associated error:
Error in switch(eventReactive(input$Cluster_method, "DBscan"), Kmeans = numericInput(inputId = "n_clusters", :
EXPR must be a length 1 vector
Any suggestions?
Thanks,