Closed gurol closed 6 years ago
I think this bug has long been fixed. The demo you linked to uses a very old version of Shiny. The current version of the application is at: https://gallery.shinyapps.io/024-optgroup-selectize/
Where did you find the link to demo.shinyapps.io?
@wch Please feel free to edit my reply there to point to the official examples :)
I have Shiny 1.0.5 on macOS and it behaves the same on my own example.
@gurol when you say it "behaves the same", do you mean it behaves like the example at gallery.shinyapps.io?
Yes, exactly. It behaves incorrectly as I explained in this issue.
I'm sorry @wch, I misundestood your question. My example behaves incorrectly like the example at demo.shinyapps.io on macOS, RStudio Version 1.1.419, and shiny 1.0.5.
Can you provide a reproducible example, and the output devtools::session_info()
?
Here is the example (please, change the extension to '.R' by removing '.txt').
"2nd input" shows 'Metrics (2nd Level)' group as an element without showing its only one element ('MCC').
> devtools::session_info()
Session info -----------------------------------------------------------------------------------------------
setting value
version R version 3.4.3 (2017-11-30)
system x86_64, darwin15.6.0
ui RStudio (1.1.419)
language (EN)
collate tr_TR.UTF-8
tz Europe/Istanbul
date 2018-02-08
Packages ---------------------------------------------------------------------------------------------------
package * version date source
abind 1.4-5 2016-07-21 CRAN (R 3.4.0)
Amelia * 1.7.4 2015-12-06 CRAN (R 3.4.0)
ape * 5.0 2017-10-30 CRAN (R 3.4.2)
assertthat 0.2.0 2017-04-11 CRAN (R 3.4.0)
backports 1.1.2 2017-12-13 CRAN (R 3.4.3)
base * 3.4.3 2017-12-07 local
bindr 0.1 2016-11-13 CRAN (R 3.4.0)
bindrcpp * 0.2 2017-06-17 CRAN (R 3.4.0)
bitops 1.0-6 2013-08-17 CRAN (R 3.4.0)
BlandAltmanLeh * 0.3.1 2015-12-23 CRAN (R 3.4.0)
caTools 1.17.1 2014-09-10 CRAN (R 3.4.0)
cellranger 1.1.0 2016-07-27 CRAN (R 3.4.0)
class 7.3-14 2015-08-30 CRAN (R 3.4.3)
cluster 2.0.6 2017-03-10 CRAN (R 3.4.3)
colorspace 1.3-2 2016-12-14 CRAN (R 3.4.0)
compiler 3.4.3 2017-12-07 local
corrplot * 0.84 2017-10-16 CRAN (R 3.4.2)
crosstalk 1.0.0 2016-12-21 CRAN (R 3.4.0)
d3vennR * 0.1 2017-06-02 Github (timelyportfolio/d3vennR@f6cb057)
data.table 1.10.4-3 2017-10-27 CRAN (R 3.4.2)
datasets * 3.4.3 2017-12-07 local
deldir 0.1-14 2017-04-22 CRAN (R 3.4.0)
dendextend * 1.6.0 2017-11-13 CRAN (R 3.4.2)
DEoptimR 1.0-8 2016-11-19 CRAN (R 3.4.0)
devtools 1.13.4 2017-11-09 CRAN (R 3.4.2)
digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
diptest 0.75-7 2016-12-05 CRAN (R 3.4.0)
dplyr * 0.7.4 2017-09-28 CRAN (R 3.4.2)
e1071 * 1.6-8 2017-02-02 CRAN (R 3.4.0)
evaluate 0.10.1 2017-06-24 CRAN (R 3.4.0)
flexmix 2.3-14 2017-04-28 CRAN (R 3.4.0)
foreign 0.8-69 2017-06-22 CRAN (R 3.4.3)
fpc 2.1-11 2018-01-13 CRAN (R 3.4.3)
futile.logger * 1.4.3 2016-07-10 CRAN (R 3.4.0)
futile.options 1.0.0 2010-04-06 CRAN (R 3.4.0)
gdata 2.18.0 2017-06-06 CRAN (R 3.4.0)
ggplot2 * 2.2.1 2016-12-30 CRAN (R 3.4.0)
glue 1.2.0 2017-10-29 CRAN (R 3.4.2)
goftest 1.1-1 2017-04-03 CRAN (R 3.4.0)
gplots * 3.0.1 2016-03-30 CRAN (R 3.4.0)
graphics * 3.4.3 2017-12-07 local
grDevices * 3.4.3 2017-12-07 local
grid * 3.4.3 2017-12-07 local
gridExtra * 2.3 2017-09-09 CRAN (R 3.4.1)
gtable 0.2.0 2016-02-26 CRAN (R 3.4.0)
gtools 3.5.0 2015-05-29 CRAN (R 3.4.0)
hexbin * 1.27.2 2018-01-15 CRAN (R 3.4.3)
htmltools 0.3.6 2017-04-28 CRAN (R 3.4.0)
htmlwidgets * 1.0 2018-01-20 CRAN (R 3.4.3)
httpuv 1.3.5 2017-07-04 CRAN (R 3.4.1)
httr 1.3.1 2017-08-20 CRAN (R 3.4.1)
jsonlite 1.5 2017-06-01 CRAN (R 3.4.0)
kernlab 0.9-25 2016-10-03 CRAN (R 3.4.0)
KernSmooth 2.23-15 2015-06-29 CRAN (R 3.4.3)
knitr * 1.19 2018-01-29 CRAN (R 3.4.3)
labeling 0.3 2014-08-23 CRAN (R 3.4.0)
lambda.r 1.2 2017-09-16 CRAN (R 3.4.1)
lattice 0.20-35 2017-03-25 CRAN (R 3.4.3)
lazyeval 0.2.1 2017-10-29 CRAN (R 3.4.2)
magrittr 1.5 2014-11-22 CRAN (R 3.4.0)
MASS 7.3-48 2017-12-25 CRAN (R 3.4.3)
Matrix 1.2-12 2017-11-20 CRAN (R 3.4.3)
mclust 5.4 2017-11-22 CRAN (R 3.4.3)
memoise 1.1.0 2017-04-21 CRAN (R 3.4.0)
methods * 3.4.3 2017-12-07 local
mgcv 1.8-23 2018-01-15 CRAN (R 3.4.3)
mime 0.5 2016-07-07 CRAN (R 3.4.0)
misc3d 0.8-4 2013-01-25 CRAN (R 3.4.0)
modeltools 0.2-21 2013-09-02 CRAN (R 3.4.0)
mongolite * 1.5 2018-01-03 CRAN (R 3.4.3)
munsell 0.4.3 2016-02-13 CRAN (R 3.4.0)
mvtnorm 1.0-7 2018-01-25 CRAN (R 3.4.3)
nlme * 3.1-131 2017-02-06 CRAN (R 3.4.3)
nnet 7.3-12 2016-02-02 CRAN (R 3.4.3)
pacman 0.4.6 2017-05-14 CRAN (R 3.4.0)
pander * 0.6.1 2017-08-06 CRAN (R 3.4.1)
parallel * 3.4.3 2017-12-07 local
PerformanceAnalytics * 1.4.3541 2014-09-16 CRAN (R 3.4.0)
pillar 1.1.0 2018-01-14 CRAN (R 3.4.3)
pkgconfig 2.0.1 2017-03-21 CRAN (R 3.4.0)
plot3D * 1.1.1 2017-08-28 CRAN (R 3.4.1)
plot3Drgl * 1.0.1 2016-01-18 CRAN (R 3.4.0)
plotly * 4.7.1 2017-07-29 CRAN (R 3.4.1)
plyr 1.8.4 2016-06-08 CRAN (R 3.4.0)
polyclip 1.6-1 2017-03-22 CRAN (R 3.4.0)
prabclus 2.2-6 2015-01-14 CRAN (R 3.4.0)
purrr 0.2.4 2017-10-18 CRAN (R 3.4.2)
R6 2.2.2 2017-06-17 CRAN (R 3.4.0)
rapport * 1.0 2015-11-18 CRAN (R 3.4.0)
rapportools 1.0 2014-01-07 CRAN (R 3.4.0)
Rarity * 1.3-6 2016-12-23 CRAN (R 3.4.0)
RColorBrewer * 1.1-2 2014-12-07 CRAN (R 3.4.0)
Rcpp * 0.12.15 2018-01-20 CRAN (R 3.4.3)
readxl * 1.0.0 2017-04-18 CRAN (R 3.4.0)
rgl * 0.99.9 2018-01-13 CRAN (R 3.4.3)
rlang 0.1.6 2017-12-21 CRAN (R 3.4.3)
rmarkdown 1.8 2017-11-17 CRAN (R 3.4.2)
robustbase 0.92-8 2017-11-01 CRAN (R 3.4.2)
rpart * 4.1-12 2018-01-12 CRAN (R 3.4.3)
rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3)
rsconnect 0.8.5 2017-08-23 CRAN (R 3.4.1)
rstudioapi 0.7 2017-09-07 cran (@0.7)
scales 0.5.0 2017-08-24 CRAN (R 3.4.1)
shiny * 1.0.5 2017-08-23 CRAN (R 3.4.1)
spatstat * 1.55-0 2018-01-29 CRAN (R 3.4.3)
spatstat.data * 1.2-0 2017-11-20 CRAN (R 3.4.3)
spatstat.utils 1.8-0 2017-11-20 CRAN (R 3.4.3)
stats * 3.4.3 2017-12-07 local
stats4 3.4.3 2017-12-07 local
stringi 1.1.6 2017-11-17 CRAN (R 3.4.2)
stringr 1.2.0 2017-02-18 CRAN (R 3.4.0)
tensor 1.5 2012-05-05 CRAN (R 3.4.0)
tibble 1.4.2 2018-01-22 CRAN (R 3.4.3)
tidyr 0.8.0 2018-01-29 CRAN (R 3.4.3)
tools 3.4.3 2017-12-07 local
trimcluster 0.1-2 2012-10-29 CRAN (R 3.4.0)
UpSetR * 1.3.3 2017-03-21 CRAN (R 3.4.0)
utils * 3.4.3 2017-12-07 local
VennDiagram * 1.6.18 2017-11-21 CRAN (R 3.4.3)
viridis 0.5.0 2018-02-02 CRAN (R 3.4.3)
viridisLite 0.3.0 2018-02-01 CRAN (R 3.4.3)
whisker 0.3-2 2013-04-28 CRAN (R 3.4.0)
withr 2.1.1 2017-12-19 CRAN (R 3.4.3)
xtable * 1.8-2 2016-02-05 CRAN (R 3.4.0)
xts * 0.10-1 2017-12-20 CRAN (R 3.4.3)
yaml 2.1.16 2017-12-12 CRAN (R 3.4.3)
zoo * 1.8-1 2018-01-08 CRAN (R 3.4.3)
Here is a minimal version of your app:
library(shiny)
ui <- fluidPage(
sidebarPanel(
selectInput(inputId='metric_name_1',
label='1st input:',
choices=list(
'Metrics (Base)' = c('TPR', 'FNR', 'TNR', 'FPR', 'ACC'),
'Metrics (1st Level)' = c('BACC', 'Gm', 'Fm', 'CK'),
'Metrics (2nd Level)' = c('MCC')
)
)
)
)
server <- function(input, output) {
}
shinyApp(ui=ui, server=server)
The issue is here:
'Metrics (2nd Level)' = c('MCC')
It is indistinguishable from this, because of how c()
works:
'Metrics (2nd Level)' = 'MCC'
That is why Metrics (2nd Level)
shows up as an option. The workarounds mentioned elsewhere are to do one of these:
'Metrics (2nd Level)' = list('MCC')
'Metrics (2nd Level)' = c(MCC = 'MCC')
Thank you so much @wch
Hi @wch, I am still having this issue. I have checked the shiny version.
packageVersion('shiny') [1] ‘1.0.5’ In my data Product Type "BEER" has only one subtype "BEER" and the input dropdown shows "Select Input" instead of "BEER". Could you help please.
The code is: library(shiny) library(dplyr) library(ggplot2)
bcl<-read.csv('bcl-data.csv',header = TRUE)
ui <- fluidPage( titlePanel("BC liquor store prices"), sidebarLayout( sidebarPanel( sliderInput("priceInput", "Price", min = 0, max = 100, value = c(25, 40), pre = "$"), uiOutput("producttype"), uiOutput("subtype"), uiOutput("countryOutput")
),
mainPanel(
plotOutput("coolplot"),
br(),br(),
tableOutput("results")
)
)
)
server <- function(input, output) { output$countryOutput <- renderUI({ selectInput("countryInput", "Country", sort(unique(bcl$Country)), selected = "CANADA") })
output$producttype <- renderUI({ selectInput("productinput", "Product Type", sort(unique(bcl$Type)), selected = "WINE") }) output$subtype<-renderUI({
a=subset(bcl,Type %in% input$productinput,select = Subtype)
b1 <- unique(a)
selectInput("subtypeinput","Select product sub type",
choices=b1 )
})
filtered <- reactive({ bcl %>% filter(Price >= input$priceInput[1], Price <= input$priceInput[2], Type == input$productinput, Subtype ==input$subtypeinput, Country == input$countryInput) })
output$coolplot<-renderPlot({ filtered() ggplot(filtered(), aes(Alcohol_Content)) + geom_histogram() })
output$results<-renderTable({ filtered()
})
} shinyApp(ui = ui, server = server)
As informed in issue #520 there is optgroup support in the
choices
argument in selectInput()/selectizeInput(). But, when there is only one element in a group it shows the group name as an element and does not show the element.You can seen this on the sample kindly provided by @yihui at https://demo.shinyapps.io/024-optgroup-selectize/.
As seen in the code
Middle = c(Iowa = 'IA')
, 'Iowa' is the only element in 'Middle' group. But when you open thex2
input select, you see 'Middle' as an element (it should be displayed as a group like 'Western' and 'Iowa' is not seen.