没有显示闪亮的图

时间:2019-01-13 04:47:24

标签: r shiny

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

基于图像的图未显示在我的闪亮应用程序中。看起来好像浏览器找不到图像。其他基于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      

预先感谢

1 个答案:

答案 0 :(得分:0)

我实际上发现了问题。我的R安装出现问题。它没有找到闪亮产生的图像的路径。卸载并重新安装R解决了该问题。甚至不需要更新任何软件包或任何东西