slickR icon indicating copy to clipboard operation
slickR copied to clipboard

shiny htmltools error

Open wildbio opened this issue 5 years ago • 3 comments

When I try to render a slickR slideshow in my R Shiny UI, I get this error message: image

The corresponding output from the R console is as follows: image

I've verified that I have not specified any white space arguments in the slickR context, in my css, or anywhere else in the app. The message leads me to believe that the error is somewhere in the communication between slickR and htmltools.

Here is a somewhat simplified, reproducible example that produces the error on my computer:

library(shiny)
library(slickR)
library(htmltools)

ui <- fluidPage(
        sidebarLayout(
                sidebarPanel(
                        h3("Select a folder of photos to view as a slideshow"),
                        actionButton(inputId = "choosePhotos", label = HTML("<font size = 4>Click to Choose Folder</font>"), 
                                     style="color: #fff; background-color: #6faade; border-color: #5491c7; width: 100%"),
                        uiOutput("selectedPhotos"),
                        br(),
                        actionButton('displayPhotos',HTML('<font size = 5><b>Display Photos</b></font>'), 
                                     style="color: #fff; background-color: #337ab7; border-color: #2e6da4; width: 100%")
                ),
                mainPanel(
                        uiOutput(outputId = "slideshow")  
                )
        )
        
)


server <- function(input, output, session) {
        observeEvent(input$choosePhotos, {
                current_folder <- choose.dir("")
                if(!is.na(current_folder)){
                        output$selectedPhotos <- renderUI({
                                checkboxGroupInput(inputId = "selectedPhotos", label = NULL,
                                                   choices = current_folder, selected = current_folder)
                        })
                }
        })
        
        output$slideshow <- renderUI({
                if (input$displayPhotos == 0){
                        return()
                }
                else {
                        isolate({ 
                                photos <- list.files(input$selectedPhotos, pattern = "*.JPG$", recursive = TRUE, full.names = TRUE)
                                
                                output$slickr <- renderSlickR({
                                        if(length(photos)<30){
                                                slickR::slickR(photos, height = "400px") +
                                                        settings(dots = T)
                                        } else {
                                                photo_sample <- sample(photos, 30)
                                                slickR::slickR(photo_sample, height = "400px") +
                                                        settings(dots = T)
                                        }
                                })
                                list(h1(HTML("<center><font color=\"#3c8dbc\" style = \"text-shadow: 1.5px 1.5px #4d3a7d\"><b>VIEW PHOTOS</b></font></center>")),
                                     br(),
                                     h4(HTML("Scroll through randomly selected motion photos in the slideshow below")),
                                     br(),
                                     slickROutput("slickr")
                                )
                        })
                }
        })
        
        
}

shinyApp(ui = ui, server = server)

I'd appreciate any and all help! Thanks!

wildbio avatar Mar 19 '20 21:03 wildbio

Can you please attach your sessionInfo()

Thanks

yonicd avatar Mar 19 '20 23:03 yonicd

Listening on http://127.0.0.1:4114
Warning: Error in choose.dir: could not find function "choose.dir"
  [No stack trace available]

I am guessing you are on a windows machine.

If i change that to a directory on my machine the app runs ok.

My initial guess is that one of your packages is not up to date. I have seen this error before in older versions on htmltools.

Here is a sessioninfo for you to compare with to see if there are any differences.

session info

─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.1 (2019-07-05)
 os       macOS Mojave 10.14.5        
 system   x86_64, darwin15.6.0        
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/New_York            
 date     2020-03-19                  

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version    date       lib source                           
 assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.6.0)                   
 backports     1.1.5      2019-10-02 [1] CRAN (R 3.6.0)                   
 base64enc     0.1-3      2015-07-28 [1] CRAN (R 3.6.0)                   
 cli           2.0.2      2020-02-28 [1] CRAN (R 3.6.0)                   
 clipr         0.7.0      2019-07-23 [1] CRAN (R 3.6.0)                   
 crayon        1.3.4      2017-09-16 [1] CRAN (R 3.6.0)                   
 desc          1.2.0      2019-12-01 [1] Github (r-lib/desc@61205f6)      
 details       0.2.1      2020-01-12 [1] local                            
 digest        0.6.25     2020-02-23 [1] CRAN (R 3.6.0)                   
 fansi         0.4.1      2020-01-08 [1] CRAN (R 3.6.0)                   
 fastmap       1.0.1      2019-10-08 [1] CRAN (R 3.6.0)                   
 glue          1.3.2      2020-03-12 [1] CRAN (R 3.6.0)                   
 htmltools   * 0.4.0      2019-10-04 [1] CRAN (R 3.6.0)                   
 htmlwidgets   1.5.1      2019-10-08 [1] CRAN (R 3.6.0)                   
 httpuv        1.5.2      2019-09-11 [1] CRAN (R 3.6.0)                   
 httr          1.4.1      2019-08-05 [1] CRAN (R 3.6.0)                   
 jsonlite      1.6.1      2020-02-02 [1] CRAN (R 3.6.0)                   
 knitr         1.28       2020-02-06 [1] CRAN (R 3.6.0)                   
 later         1.0.0.9002 2020-03-03 [1] Github (r-lib/later@0fb877a)     
 lifecycle     0.1.0      2019-08-01 [1] CRAN (R 3.6.0)                   
 magrittr      1.5        2014-11-22 [1] CRAN (R 3.6.0)                   
 mime          0.9        2020-02-04 [1] CRAN (R 3.6.0)                   
 packrat       0.5.0      2018-11-14 [1] CRAN (R 3.6.0)                   
 png           0.1-7      2013-12-03 [1] CRAN (R 3.6.0)                   
 promises      1.1.0.9000 2020-03-03 [1] Github (rstudio/promises@627dfc6)
 R6            2.4.1      2019-11-12 [1] CRAN (R 3.6.0)                   
 Rcpp          1.0.4      2020-03-17 [1] CRAN (R 3.6.0)                   
 rlang         0.4.5      2020-03-01 [1] CRAN (R 3.6.0)                   
 rprojroot     1.3-2      2018-01-03 [1] CRAN (R 3.6.0)                   
 rsconnect     0.8.15     2019-07-22 [1] CRAN (R 3.6.0)                   
 rstudioapi    0.11       2020-02-07 [1] CRAN (R 3.6.1)                   
 sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 3.6.0)                   
 shiny       * 1.4.0      2019-10-10 [1] CRAN (R 3.6.0)                   
 slickR      * 0.5.0001   2020-02-28 [1] local                            
 withr         2.1.2      2018-03-15 [1] CRAN (R 3.6.0)                   
 xfun          0.12       2020-01-13 [1] CRAN (R 3.6.0)                   
 xml2          1.2.5      2020-03-11 [1] CRAN (R 3.6.0)                   
 xtable        1.8-4      2019-04-21 [1] CRAN (R 3.6.0)                   
 yaml          2.2.1      2020-02-01 [1] CRAN (R 3.6.0)                   

[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library


yonicd avatar Mar 19 '20 23:03 yonicd

Ah geez, I'm so sorry, these messages went to my junk folder, and I apparently forgot about the issue till now. I am running this on a Windows computer, and choose.dir is from the utils package. I've attached my sessioninfo below--it looks like some of our package versions are indeed different. I'll try updating everything and see where that gets me. Thanks!

Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] tools     stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ggpubr_0.2.5         magrittr_1.5         plotly_4.9.2         slickR_0.4.9         tippy_0.0.1         
 [6] htmltools_0.3.6      V8_3.0.2             htmlwidgets_1.3      base64enc_0.1-3      xml2_1.2.0          
[11] lifecycle_0.2.0      DT_0.8               exifr_0.3.1          forcats_0.4.0        stringr_1.4.0       
[16] dplyr_0.8.1          purrr_0.3.2          readr_1.3.1          tidyr_0.8.3          tibble_2.1.3        
[21] ggplot2_3.2.0        tidyverse_1.2.1      shinyjs_1.1          shinycssloaders_0.3  shinydashboard_0.7.1
[26] shinyBS_0.61         shiny_1.3.2         

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1        lubridate_1.7.4   lattice_0.20-38   assertthat_0.2.1  digest_0.6.19    
 [6] mime_0.7          R6_2.4.0          cellranger_1.1.0  plyr_1.8.4        backports_1.1.4  
[11] httr_1.4.0        pillar_1.4.2      rlang_0.4.0       lazyeval_0.2.2    curl_3.3         
[16] readxl_1.3.1      rstudioapi_0.10   data.table_1.12.8 munsell_0.5.0     broom_0.5.2      
[21] compiler_3.6.0    httpuv_1.5.1      modelr_0.1.4      pkgconfig_2.0.2   tidyselect_0.2.5 
[26] viridisLite_0.3.0 crayon_1.3.4      withr_2.1.2       later_0.8.0       rappdirs_0.3.1   
[31] grid_3.6.0        nlme_3.1-139      jsonlite_1.6      xtable_1.8-4      gtable_0.3.0     
[36] scales_1.0.0      cli_1.1.0         stringi_1.4.3     ggsignif_0.6.0    promises_1.0.1   
[41] generics_0.0.2    glue_1.3.1        crosstalk_1.0.0   hms_0.4.2         yaml_2.2.0       
[46] colorspace_1.4-1  rvest_0.3.4       haven_2.1.0      ```

wildbio avatar Apr 14 '20 18:04 wildbio