gpt4 book ai didi

r - 在同一个 Shiny 的应用程序中使用 shinyjs 和 ggplot2::autoplot

转载 作者:行者123 更新时间:2023-12-01 22:10:45 27 4
gpt4 key购买 nike

我在 Shiny 的应用程序中使用函数 ggplot2::autoplot 和一个 lm 对象。
这要归功于 ggfortify 包。

在我 Shiny 的应用程序中,我还使用了 shinyjs
在下面的可重现示例中,一旦我取消注释 library(shinyjs) & useShinyjs() 我就会收到错误:
unclass(x) 中的错误:无法取消环境

对可能的解决方法有什么想法吗?

library(shiny)
library(ggplot2)
library(ggfortify)
#library(shinyjs)

ui <- fluidPage(
#useShinyjs(),
div(
actionButton("run", "Run")
,uiOutput("ui_autoplot")
)
)

server <- function(input, output, session) {

data <- iris

rv_autoplot <- eventReactive(input$run, {
a <- lm(data = data, Sepal.Length ~ Petal.Length)
p <- autoplot(a, which = 1:6, label.size = 2, data = data)
return(p)
})

output$autoplot <- renderPlot({
req(rv_autoplot())
rv_autoplot()
})


output$ui_autoplot <- renderUI({
plotOutput("autoplot")
})
}

shinyApp(ui = ui, server = server)

我的 sessionInfo() :

R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so

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] shinyjs_0.9.1 bindrcpp_0.2 ggfortify_0.4.1 ggplot2_2.2.1 shiny_1.0.5

loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 magrittr_1.5 bindr_0.1 munsell_0.4.3 colorspace_1.3-2 xtable_1.8-2 R6_2.2.2
[8] rlang_0.1.2 plyr_1.8.4 dplyr_0.7.4 tools_3.4.1 grid_3.4.1 gtable_0.2.0 miniUI_0.1.1
[15] htmltools_0.3.6 yaml_2.1.14 lazyeval_0.2.0 digest_0.6.12 assertthat_0.2.0 tibble_1.3.4 gridExtra_2.3
[22] tidyr_0.6.3 glue_1.1.1 mime_0.5 labeling_0.3 compiler_3.4.1 scales_0.5.0 jsonlite_1.5
[29] httpuv_1.3.5 pkgconfig_2.0.1 Cairo_1.5-9

最佳答案

您可以使用命名空间调用 shinyjs 参数而不是加载库,shinyjs::useShinyjs() 似乎对我有用。

关于r - 在同一个 Shiny 的应用程序中使用 shinyjs 和 ggplot2::autoplot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48093494/

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