0

我在 RMarkdown 文档中使用闪亮的 flexdashboard。代码运行平稳,除非我想让可折叠树单击作为 selectInput 和 renderPlotly 的反应输出数据。

出现错误:在 renderCollapsibleTree 中使用 dplyr::filter 时,参数的“类型”(列表)无效。如果我不使用过滤器 - 它会绘制一个交互式但非反应性的可折叠树,它与我的 selectInput 完全没有联系。

对此有何补救措施?

library(shiny)
library(collapsibleTree)
library(plotly)
library(DT)
library(flexdashboard)
    
library(modeltime)
library(modeltime.ensemble)
library(tidymodels)
    
library(tidyverse)
library(timetk)

...skipping code...

shiny::selectInput(
    "indicator", 
    label     = "Select a Hierarchy to Forecast",
    choices   = indicator_options, 
    selectize = TRUE
)

...skipping code...

renderCollapsibleTree({
  purchases_summarized_tbl %>%

        #Filtering below returns an error output, if excluded as below 
        it works but is isolated from the reactive connection with selectInput

    #filter(identifier %in% input$indicator) %>% 

    collapsibleTree(
      hierarchy = c("state_id", "store_id", "cat_id", "dept_id", "identifier"),
      attribute = "value",
      root      = "All Stores",
      aggFun    = sum, 
      nodeSize  = "value",
      tooltip   = TRUE, 
      fontSize  = 14
    )
})

会话信息():

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

other attached packages:
 [1] d3Tree_0.2.2             timetk_2.6.1             forcats_0.5.1            stringr_1.4.0           
 [5] readr_1.4.0              tidyverse_1.3.1          yardstick_0.0.8          workflowsets_0.0.2      
 [9] workflows_0.2.2          tune_0.1.5               tidyr_1.1.3              tibble_3.1.2            
[13] rsample_0.1.0            recipes_0.1.16           purrr_0.3.4              parsnip_0.1.6           
[17] modeldata_0.1.0          infer_0.5.4              dplyr_1.0.6              dials_0.0.9             
[21] scales_1.1.1             broom_0.7.6              tidymodels_0.1.3         modeltime.ensemble_0.4.1
[25] modeltime.resample_0.2.0 modeltime_0.6.0          DT_0.18                  plotly_4.9.4            
[29] ggplot2_3.3.3            collapsibleTree_0.1.7    shiny_1.6.0             

loaded via a namespace (and not attached):
  [1] colorspace_2.0-1     ellipsis_0.3.2       class_7.3-18         fs_1.5.0             base64enc_0.1-3     
  [6] rstudioapi_0.13      listenv_0.8.0        furrr_0.2.2          prodlim_2019.11.13   fansi_0.5.0         
 [11] lubridate_1.7.10     xml2_1.3.2           codetools_0.2-18     splines_4.0.5        doParallel_1.0.16   
 [16] knitr_1.33           jsonlite_1.7.2       pROC_1.17.0.1        dbplyr_2.1.1         data.tree_1.0.0     
 [21] compiler_4.0.5       httr_1.4.2           backports_1.2.1      assertthat_0.2.1     Matrix_1.3-2        
 [26] fastmap_1.1.0        lazyeval_0.2.2       cli_2.5.0            later_1.2.0          htmltools_0.5.1.1   
 [31] tools_4.0.5          gtable_0.3.0         glue_1.4.2           Rcpp_1.0.6           cellranger_1.1.0    
 [36] jquerylib_0.1.4      DiceDesign_1.9       vctrs_0.3.8          iterators_1.0.13     timeDate_3043.102   
 [41] gower_0.2.2          xfun_0.23            globals_0.14.0       rvest_1.0.0          mime_0.10           
 [46] lifecycle_1.0.0      future_1.21.0        MASS_7.3-53.1        zoo_1.8-9            ipred_0.9-11        
 [51] hms_1.1.0            promises_1.2.0.1     parallel_4.0.5       lightgbm_3.2.1       flexdashboard_0.5.2 
 [56] yaml_2.2.1           StanHeaders_2.21.0-7 sass_0.4.0           rpart_4.1-15         stringi_1.6.2       
 [61] foreach_1.5.1        lhs_1.1.1            lava_1.6.9           repr_1.1.3           rlang_0.4.11        
 [66] pkgconfig_2.0.3      evaluate_0.14        lattice_0.20-41      htmlwidgets_1.5.3    tidyselect_1.1.1    
 [71] parallelly_1.26.0    plyr_1.8.6           magrittr_2.0.1       R6_2.5.0             generics_0.1.0      
 [76] DBI_1.1.1            haven_2.4.1          pillar_1.6.1         withr_2.4.2          xts_0.12.1          
 [81] survival_3.2-10      nnet_7.3-15          modelr_0.1.8         crayon_1.4.1         xgboost_1.4.1.1     
 [86] catboost_0.26        utf8_1.2.1           rmarkdown_2.8.6      readxl_1.3.1         grid_4.0.5          
 [91] data.table_1.14.0    reprex_2.0.0         digest_0.6.27        xtable_1.8-4         httpuv_1.6.1        
 [96] RcppParallel_5.1.4   munsell_0.5.0        GPfit_1.0-8          viridisLite_0.4.0    skimr_2.1.3         
[101] bslib_0.2.5.1
4

0 回答 0