gpt4 book ai didi

R shiny : Error in plotly_build: argument "p" missing, 没有默认值

转载 作者:行者123 更新时间:2023-12-05 08:52:25 34 4
gpt4 key购买 nike

当我运行我的 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
})

最佳答案

我终于找到了解决方案。该错误是由于我同时使用了 plotly。和 formattable包裹。可以在这里找到解决方案: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"))))

关于R shiny : Error in plotly_build: argument "p" missing, 没有默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56840172/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com