gpt4 book ai didi

r - ggiraph图未出现在 Shiny 的应用程序中,但可在RStudio中使用

转载 作者:行者123 更新时间:2023-12-03 16:11:33 24 4
gpt4 key购买 nike

我真的很想使用ggiraph在我的shiny应用程序中添加工具提示。但是,当我尝试这样做时,该图不出现。在下面的示例中,我使用了plotOutputggiraphOutput,但仅出现了my.plot。我可以在RStudio中生成交互式图,而不能在应用程序中生成。我的实现有问题吗?还是可能存在兼容性问题(下面的sessionInfo())?谢谢!

library(ggiraph)
library(shiny)
library(ggplot2)
ui <- fluidPage(
fluidRow(
column(6,plotOutput(outputId ="my.plot")),
column(6,ggiraphOutput(outputId = "interactive.plot"))
)
)

server <- function(input, output){
output$my.plot <- renderPlot({
data = data.frame(x = 1:10, y= rnorm(10), z = 11:20)
ggplot(data, aes(x = x, y = y)) + geom_col()

#girafe(ggobj = xx)
})
output$interactive.plot <- renderggiraph({
data = data.frame(x = 1:10, y= rnorm(10), z = 11:20)
gg <- ggplot(data, aes(x = 1:10, y = rnorm(10), z = 11:20)) + geom_col_interactive(aes(tooltip = z))
girafe(ggobj = gg)
})
}

shinyApp(ui, server)

这是我的 sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] gdtools_0.2.1 ggplot2_3.2.1 shiny_1.4.0 dplyr_0.8.4 ggiraph_0.7.0

loaded via a namespace (and not attached):
[1] tidyselect_1.0.0 remotes_2.1.0 purrr_0.3.3 colorspace_1.4-1 testthat_2.3.1 htmltools_0.4.0 usethis_1.5.1
[8] yaml_2.2.1 rlang_0.4.4 pkgbuild_1.0.6 pillar_1.4.3 later_1.0.0 glue_1.3.1 withr_2.1.2
[15] sessioninfo_1.1.1 uuid_0.1-4 lifecycle_0.1.0 munsell_0.5.0 gtable_0.3.0 devtools_2.2.1 htmlwidgets_1.5.1
[22] memoise_1.1.0 labeling_0.3 callr_3.4.1 fastmap_1.0.1 Cairo_1.5-11 httpuv_1.5.2 ps_1.3.0
[29] fansi_0.4.1 Rcpp_1.0.3 xtable_1.8-4 scales_1.1.0 backports_1.1.5 promises_1.1.0 desc_1.2.0
[36] pkgload_1.0.2 jsonlite_1.6.1 farver_2.0.3 mime_0.9 systemfonts_0.1.1 fs_1.3.1 digest_0.6.23
[43] processx_3.4.2 cowplot_1.0.0 grid_3.5.3 rprojroot_1.3-2 cli_2.0.1 tools_3.5.3 magrittr_1.5
[50] lazyeval_0.2.2 tibble_2.1.3 crayon_1.3.4 pkgconfig_2.0.3 ellipsis_0.3.0 xml2_1.2.2 prettyunits_1.1.1
[57] assertthat_0.2.1 rstudioapi_0.11 R6_2.4.1 compiler_3.5.3

最佳答案

我不确定100%为什么,但是问题似乎出在“”上。 (句号)在outputID名称中。如果您将其更改为

ggiraphOutput(outputId = "interactivePlot")


output$interactivePlot <- renderggiraph({ ... ])

它似乎工作得很好。这似乎已记录在 ?girafeOutput帮助页面中,但没有显示在 ?ggiraphOutput帮助页面中。

output variable to read the girafe from. Do not use special JavaScript characters such as a period . in the id, this would create a JavaScript error.



看来他们正在尝试继续使用 girafeOutputrenderGirafe

关于r - ggiraph图未出现在 Shiny 的应用程序中,但可在RStudio中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60939334/

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