RinteRface / shinydashboardPlus

extensions for shinydashboard
https://shinydashboardplus.rinterface.com
Other
454 stars 77 forks source link

Error dashboardPage() when running shinydashboardPlusGallery() #121

Closed lmsimp closed 3 years ago

lmsimp commented 3 years ago

I am currently trying to run the demo/examples as per your rinterface website and I encounter the following error with dashboardPage.

> library(shinydashboardPlus)

Attaching package: ‘shinydashboardPlus’

The following object is masked from ‘package:graphics’:

    box

> shinydashboardPlusGallery()
Loading required namespace: styler
Loading required namespace: shinyAce
Loading required namespace: shinyWidgets
Loading required namespace: shinyjqui
Loading required package: shiny

Attaching package: ‘shinydashboard’

The following objects are masked from ‘package:shinydashboardPlus’:

    box, dashboardHeader, dashboardPage, dashboardSidebar, messageItem, notificationItem, taskItem

The following object is masked from ‘package:graphics’:

    box

Attaching package: ‘shinyWidgets’

The following object is masked from ‘package:shinydashboardPlus’:

    progressBar

Attaching package: ‘shinyEffects’

The following object is masked from ‘package:shinyWidgets’:

    setShadow

Error in dashboardPage(md = FALSE, dashboardHeader(fixed = TRUE, title = tagList(span(class = "logo-lg",  : 
  unused arguments (md = FALSE, controlbar = dashboardControlbar(skin = "dark", controlbarMenu(controlbarItem(title = "Tab 1", icon = icon("desktop"), active = TRUE, sliderInput(inputId = "inputsidebar1", label = "Number of observations:", min = 0, max = 1000, value = 500)), controlbarItem(icon = icon("paint-brush"), title = "Tab 2", numericInput(inputId = "inputsidebar2", label = "Observations:", value = 10, min = 1, max = 100)))), footer = dashboardFooter(left = "By Divad Nojnarg", right = "Zurich, 2019"))
In addition: There were 11 warnings (use warnings() to see them)

> sessionInfo()
R Under development (unstable) (2020-10-17 r79346)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] shinyEffects_0.1.0       styler_1.4.1             shinyAce_0.4.1           shinyWidgets_0.6.0       shinydashboard_0.7.1    
[6] shinyjqui_0.4.0          shiny_1.6.0              shinydashboardPlus_2.0.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5        pillar_1.5.1      compiler_4.1.0    bslib_0.2.4       later_1.1.0.1     jquerylib_0.1.3   R.utils_2.10.1   
 [8] R.methodsS3_1.8.1 tools_4.1.0       digest_0.6.27     jsonlite_1.7.2    lifecycle_1.0.0   tibble_3.1.0      R.cache_0.14.0   
[15] pkgconfig_2.0.3   rlang_0.4.10      fastmap_1.0.1     withr_2.3.0       vctrs_0.3.6       sass_0.3.1        htmlwidgets_1.5.2
[22] R6_2.5.0          fansi_0.4.2       purrr_0.3.4       magrittr_2.0.1    backports_1.1.10  promises_1.1.1    ellipsis_0.3.1   
[29] htmltools_0.5.1.1 mime_0.10         xtable_1.8-4      httpuv_1.5.4      utf8_1.2.1        crayon_1.4.1      R.oo_1.24.0 
lmsimp commented 3 years ago

Okay, so I see this is because R is trying to use the dashboardPage and dashboardHeader functions from the shinydashboard package and not shinydashboardPlus.

If I define the following -

dashboardHeader <- shinydashboardPlus::dashboardHeader
dashboardPage <- shinydashboardPlus::dashboardPage

then run the example, it works.

What is the best way to avoid this scenario in general when you have the same function names in different packages?

lmsimp commented 3 years ago

Again, answering the above. I see I need to explicitly load shinydashboard and then shinydashboardPlus to ensure the order of loading is correct and functions are not masked.

Specifically,

library(shinydashboard)
library(shinydashboardPlus)
shinydashboardPlusGallery()