R Shiny:plotly_build中的错误:参数“ p”缺失,没有默认值

时间:2019-07-01 17:46:51

标签: r shinydashboard

运行我的Shinyapp时,plotly_build出现错误:

Error in plotly_build: argument "p" missing, with no default value

这很奇怪,因为我没有使用plotly_build函数,并且因为唯一未显示的项是格式表。 实际上,这链接到我的上一篇文章(Reactive formattable in shiny?)。当我使用解决方案中提供的代码时,它可以工作。但是我尝试将此代码应用于我的实际应用,出现了此错误。 奇怪的是,在实际的应用程序中尝试过之后,我在提供的解决方案中再次尝试,并出现了相同的错误(尽管之前运行正常)。

我知道没有可复制的示例来修复它并不容易,但是也许有人已经遇到了这种问题。这是我的sessionInfo()

R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8    
 [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8    LC_PAPER=fr_FR.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] WDI_2.6.0            easypackages_0.1.0   lmtest_0.9-37        zoo_1.8-6            usethis_1.5.0        devtools_2.0.2      
 [7] xtable_1.8-4         data.table_1.12.2    openxlsx_4.1.0.1     dplyr_0.8.2          broom_0.5.2          ECharts2Shiny_0.2.13
[13] factoextra_1.0.5     FactoMineR_1.41      plotly_4.9.0         ggplot2_3.2.0        formattable_0.2.0.1  shinydashboard_0.7.1
[19] plm_2.0-2            tseries_0.10-47      DT_0.7               haven_2.1.0          tidyselect_0.2.5     readxl_1.3.1        
[25] shiny_1.3.2         

loaded via a namespace (and not attached):
 [1] nlme_3.1-140         fs_1.3.1             xts_0.11-2           httr_1.4.0           rprojroot_1.3-2      tools_3.6.0         
 [7] backports_1.1.4      R6_2.4.0             lazyeval_0.2.2       colorspace_1.4-1     withr_2.1.2          prettyunits_1.0.2   
[13] processx_3.3.1       curl_3.3             compiler_3.6.0       cli_1.1.0            flashClust_1.01-2    desc_1.2.0          
[19] sandwich_2.5-1       labeling_0.3         scales_1.0.0         readr_1.3.1          quadprog_1.5-7       callr_3.2.0         
[25] stringr_1.4.0        digest_0.6.19        rmarkdown_1.13       pkgconfig_2.0.2      htmltools_0.3.6      sessioninfo_1.1.1   
[31] bibtex_0.4.2         htmlwidgets_1.3      rlang_0.4.0          TTR_0.23-4           rstudioapi_0.10      quantmod_0.4-15     
[37] generics_0.0.2       jsonlite_1.6         crosstalk_1.0.0      zip_2.0.2            magrittr_1.5         Formula_1.2-3       
[43] leaps_3.0            Rcpp_1.0.1           munsell_0.5.0        yaml_2.2.0           scatterplot3d_0.3-41 stringi_1.4.3       
[49] RJSONIO_1.3-1.2      gbRd_0.4-11          MASS_7.3-51.4        pkgbuild_1.0.3       grid_3.6.0           promises_1.0.1      
[55] ggrepel_0.8.1        bdsmatrix_1.3-3      forcats_0.4.0        crayon_1.3.4         lattice_0.20-38      hms_0.4.2           
[61] knitr_1.23           ps_1.3.0             pillar_1.4.2         pkgload_1.0.2        glue_1.3.1           evaluate_0.14       
[67] remotes_2.1.0        httpuv_1.5.1         Rdpack_0.11-0        miscTools_0.6-22     cellranger_1.1.0     gtable_0.3.0        
[73] purrr_0.3.2          tidyr_0.8.3          assertthat_0.2.1     xfun_0.8             mime_0.7             later_0.8.0         
[79] viridisLite_0.3.0    tibble_2.1.3         memoise_1.1.0        cluster_2.1.0        maxLik_1.3-6  

和我的表格代码(不可复制,因为此错误未出现在我在上面的链接中提供的可复制示例中):

  lmod <- reactive({
    lm(as.formula(paste(input$v.dependent, "~", paste(input$predictor, collapse = "+"))), data = user.selection())
  })

  output$res.reg <- renderFormattable({
    tmp <- summary(lmod())$coefficients
    colnames(tmp) <- c("Coefficients", "SD", "t statistic", "Pvalue")
    tmp <- signif(x = tmp, digits = 3)
    tmp <- as.data.frame(tmp)
    tmp <- formattable(tmp, list(
      Pvalue = formatter("span", style = x ~ style(color = ifelse(x < 0.05, "red", "black"))))
    )
    tmp
  })

1 个答案:

答案 0 :(得分:0)

我终于找到了解决方案。该错误是由于我同时使用plotlyformattable软件包引起的。该解决方案可以在这里找到:Using formattable and plotly simultaneously

适用于我的问题,我只需要替换

formatter("span", style = x ~ style(color = ifelse(x < 0.05, "red", "black"))))

通过

formatter("span", style = x ~ formattable::style(color = ifelse(x < 0.05, "red", "black"))))