【问题标题】:Shiny plots are not being displayed没有显示闪亮的情节
【发布时间】:2019-01-14 21:37:17
【问题描述】:

我在开发另一个应用程序时发现了这个问题,但下面是一个直接来自闪亮网站的可重现示例。

基于图像的绘图未显示在我闪亮的应用程序中。看起来好像浏览器找不到图像。其他基于 javascript 的绘图工作正常。这似乎是一个路径问题,但我不确定问题是什么。

应用程序 直接来自闪亮的网站应该可以工作

library(shiny)

ui<-pageWithSidebar(
    headerPanel('Iris k-means clustering'),
    sidebarPanel(
      selectInput('xcol', 'X Variable', names(iris)),
      selectInput('ycol', 'Y Variable', names(iris),
                  selected=names(iris)[[2]]),
      numericInput('clusters', 'Cluster count', 3,
                   min = 1, max = 9)
    ),
    mainPanel(
      plotOutput('plot1')
    )
  )



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

  # Combine the selected variables into a new data frame
  selectedData <- reactive({
    iris[, c(input$xcol, input$ycol)]
  })

  clusters <- reactive({
    kmeans(selectedData(), input$clusters)
  })

  output$plot1 <- renderPlot({
    palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
              "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))

    par(mar = c(5.1, 4.1, 0, 1))
    plot(selectedData(),
         col = clusters()$cluster,
         pch = 20, cex = 3)
    points(clusters()$centers, pch = 4, cex = 4, lwd = 4)
  })

}


shinyApp(ui, server)

会话

R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

Matrix products: default
BLAS: /opt/microsoft/ropen/3.5.1/lib64/R/lib/libRblas.so
LAPACK: /opt/microsoft/ropen/3.5.1/lib64/R/lib/libRlapack.so

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

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

other attached packages:
[1] shiny_1.2.0.9001     RevoUtils_11.0.1     RevoUtilsMath_11.0.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0        knitr_1.21        magrittr_1.5      devtools_1.13.6   xtable_1.8-3      R6_2.3.0          rlang_0.3.0.1    
 [8] stringr_1.3.1     httr_1.4.0        tools_3.5.1       xfun_0.4          git2r_0.23.0      withr_2.1.2       htmltools_0.3.6  
[15] yaml_2.2.0        digest_0.6.18     later_0.7.5.9001  base64enc_0.1-3   promises_1.0.1    rsconnect_0.8.12  curl_3.2         
[22] memoise_1.1.0     evaluate_0.12     mime_0.6          rmarkdown_1.11    stringi_1.2.4     compiler_3.5.1    jsonlite_1.6     
[29] httpuv_1.4.5.9002 Cairo_1.5-9      

提前致谢

【问题讨论】:

  • 你安装了一个开发版的闪亮。您是否尝试过删除它,从 CRAN 安装一个马厩并查看是否可以修复它?

标签: r shiny


【解决方案1】:

我确实发现了问题。我的 R 安装有问题。它没有找到由闪亮创建的图像的路径。卸载并重新安装 R 解决了这个问题。甚至不需要更新任何包或任何东西

【讨论】:

    猜你喜欢
    • 2017-01-21
    • 2017-11-07
    • 1970-01-01
    • 1970-01-01
    • 2019-06-19
    • 1970-01-01
    • 1970-01-01
    • 2021-05-10
    • 2019-05-11
    相关资源
    最近更新 更多