错误:无法找到函数" chartJSRadarOutput"部署

时间:2016-10-09 22:43:51

标签: r shiny

我的闪亮应用程序在我的本地计算机上成功执行,但当我想部署它时,它会显示ERROR: could not find function "chartJSRadarOutput" 但是,我已经library(radarchart)了。

我也经历了这个https://github.com/MangoTheCat/radarchart/tree/master/inst/shiny-examples/basic,并确实告诉了它,仍然失败了。 这是我的ui.R和server.R代码的一部分:

    Server.R
server <- function(input, output) {
  library(shiny)
  library(radarchart)
  library(ggplot2)
  library(reshape2)
top_version<-read.csv("top_version.csv",header = T)
top_version<-top_version[,2:26]
  output$plot1 <- renderChartJSRadar({
    ds<-subset(top_version,top_version$ageInd==input$select1)
    labs<-c('familiarity','favorability','consideration')
    scores<-list('Women'=c(nrow(ds[ds$familiarity==1 & ds$gender==2,])/nrow(ds[ds$gender==2,]),nrow(ds[ds$favorability==1 & ds$gender==2,])/nrow(ds[ds$gender==2,]),nrow(ds[ds$consideration==1 & ds$gender==2,])/nrow(ds[ds$gender==2,])),
                   'Men'=c(nrow(ds[ds$familiarity==1 & ds$gender==1,])/nrow(ds[ds$gender==1,]),nrow(ds[ds$favorability==1 & ds$gender==1,])/nrow(ds[ds$gender==1,]),nrow(ds[ds$consideration==1 & ds$gender==1,])/nrow(ds[ds$gender==1,])))
    chartJSRadar(scores=scores, labs=labs,showToolTipLabel = T)
  })})

ui.R
column(width = 12,
      chartJSRadarOutput("plot1", width = "300", height = "100"))

有没有人有任何想法?非常感谢!

我在shinyapps.io上运行它,我在server.R

中有库

本地结果是:

> deployApp('/Users/Qiner/Downloads/ME_Analyst_Assessment_Files/visualapp')
Preparing to deploy application...DONE
Uploading bundle for application: 130647...DONE
Deploying bundle: 581557 for application: 130647 ...
Waiting for task: 266968451
  building: Parsing manifest
  building: Building image: 572450
  building: Fetching packages
  building: Installing packages
  building: Installing files
  building: Pushing image: 572450
  deploying: Starting instances
  rollforward: Activating new instances
  terminating: Stopping old instances
Application successfully deployed to https://qiner-shiny-home.shinyapps.io/visualapp/

和shinyapps.io上的错误只是:

ERROR: could not find function "chartJSRadarOutput"

包的sessioninfo是:

> sessionInfo(package = "radarchart")
R version 3.2.4 (2016-03-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
character(0)

other attached packages:
[1] radarchart_0.2.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.6         rstudioapi_0.6      magrittr_1.5        devtools_1.11.1    
 [5] grDevices_3.2.4     munsell_0.4.3       colorspace_1.2-6    xtable_1.8-2       
 [9] R6_2.1.2            httr_1.1.0          stringr_1.0.0       plyr_1.8.4         
[13] tools_3.2.4         utils_3.2.4         packrat_0.4.7-1     grid_3.2.4         
[17] gtable_0.2.0        git2r_0.14.0        withr_1.0.1         htmltools_0.3.5    
[21] stats_3.2.4         datasets_3.2.4      yaml_2.1.13         digest_0.6.10      
[25] randomForest_4.6-12 base_3.2.4          RJSONIO_1.3-0       shiny_0.13.2       
[29] reshape2_1.4.1      ggplot2_2.1.0       bitops_1.0-6        htmlwidgets_0.6    
[33] graphics_3.2.4      RCurl_1.95-4.8      curl_0.9.7          rsconnect_0.4.3    
[37] memoise_1.0.0       mime_0.4            labeling_0.3        stringi_1.1.1      
[41] shinyapps_0.4.1.8   methods_3.2.4       scales_0.4.0        jsonlite_1.0       
[45] httpuv_1.3.3 

shinyapps.io上的日志是:

2016-10-10T02:13:43.346532+00:00 shinyapps[130647]: LANG: en_US.UTF-8
2016-10-10T02:13:43.346534+00:00 shinyapps[130647]: R version: 3.2.4
2016-10-10T02:13:43.346536+00:00 shinyapps[130647]: shiny version: 0.13.2
2016-10-10T02:13:43.346550+00:00 shinyapps[130647]: rmarkdown version: NA
2016-10-10T02:13:43.346552+00:00 shinyapps[130647]: knitr version: NA
2016-10-10T02:13:43.346558+00:00 shinyapps[130647]: jsonlite version: 1.0
2016-10-10T02:13:43.346564+00:00 shinyapps[130647]: RJSONIO version: 1.3.0
2016-10-10T02:13:43.346593+00:00 shinyapps[130647]: htmltools version: 0.3.5
2016-10-10T02:13:43.523112+00:00 shinyapps[130647]: Using jsonlite for JSON processing
2016-10-10T02:13:43.527991+00:00 shinyapps[130647]: 
2016-10-10T02:13:43.527992+00:00 shinyapps[130647]: Starting R with process ID: '59'
2016-10-10T02:13:43.546168+00:00 shinyapps[130647]: Listening on http://0.0.0.0:36262
2016-10-10T02:13:43.546165+00:00 shinyapps[130647]: 
2016-10-10T02:13:43.628716+00:00 shinyapps[130647]: Warning: Error in tag: could not find function "chartJSRadarOutput"
2016-10-10T02:13:43.634773+00:00 shinyapps[130647]:     65: fluidRow
2016-10-10T02:13:43.634780+00:00 shinyapps[130647]:     53: navbarPage
2016-10-10T02:13:43.634785+00:00 shinyapps[130647]:      6: eval
2016-10-10T02:13:43.634767+00:00 shinyapps[130647]: Stack trace (innermost first):
2016-10-10T02:13:43.634774+00:00 shinyapps[130647]:     64: tag
2016-10-10T02:13:43.634779+00:00 shinyapps[130647]:     55: div
2016-10-10T02:13:43.634785+00:00 shinyapps[130647]:      5: eval
2016-10-10T02:13:43.634769+00:00 shinyapps[130647]:     72: tag
2016-10-10T02:13:43.634775+00:00 shinyapps[130647]:     62: div
2016-10-10T02:13:43.634779+00:00 shinyapps[130647]:     54: tabPanel

2016-10-10T02:13:43.634786+00:00 shinyapps[130647]:      4: eval
2016-10-10T02:13:43.634770+00:00 shinyapps[130647]:     71: tags$div
2016-10-10T02:13:43.634776+00:00 shinyapps[130647]:     59: bootstrapPage
2016-10-10T02:13:43.634782+00:00 shinyapps[130647]:     11: doTryCatch
2016-10-10T02:13:43.634787+00:00 shinyapps[130647]:      3: eval
2016-10-10T02:13:43.634771+00:00 shinyapps[130647]:     70: div
2016-10-10T02:13:43.634775+00:00 shinyapps[130647]:     61: tagList
2016-10-10T02:13:43.634781+00:00 shinyapps[130647]:     13: runApp
2016-10-10T02:13:43.634787+00:00 shinyapps[130647]:      2: eval.parent
2016-10-10T02:13:43.634771+00:00 shinyapps[130647]:     69: column
2016-10-10T02:13:43.634776+00:00 shinyapps[130647]:     60: attachDependencies
2016-10-10T02:13:43.634782+00:00 shinyapps[130647]:     12: fn
2016-10-10T02:13:43.634788+00:00 shinyapps[130647]:      1: local
2016-10-10T02:13:43.634772+00:00 shinyapps[130647]:     68: tag
2016-10-10T02:13:43.634778+00:00 shinyapps[130647]:     57: tag
2016-10-10T02:13:43.634783+00:00 shinyapps[130647]:     10: tryCatchOne
2016-10-10T02:13:43.634901+00:00 shinyapps[130647]: Error in tag("div", list(...)) : 
2016-10-10T02:13:43.634772+00:00 shinyapps[130647]:     67: tags$div
2016-10-10T02:13:43.634778+00:00 shinyapps[130647]:     56: tags$div
2016-10-10T02:13:43.634784+00:00 shinyapps[130647]:      7: connect$retry
2016-10-10T02:13:43.634903+00:00 shinyapps[130647]:   could not find function "chartJSRadarOutput"

2016-10-10T02:13:43.634773+00:00 shinyapps[130647]:     66: div
2016-10-10T02:13:43.634777+00:00 shinyapps[130647]:     58: fluidPage
2016-10-10T02:13:43.634783+00:00 shinyapps[130647]:      9: tryCatchList
2016-10-10T02:13:43.634774+00:00 shinyapps[130647]:     63: tags$div
2016-10-10T02:13:43.634781+00:00 shinyapps[130647]:     52: shinyUI
2016-10-10T02:13:43.634784+00:00 shinyapps[130647]:      8: tryCatch

1 个答案:

答案 0 :(得分:0)

您需要在两个文件中加载包。我在自己的shinyapps.io帐户上测试了这个,错误就消失了。

您的代码仍然存在我在评论中提到的错误(2016-10-10T02:14:15.159934+00:00 shinyapps[130687]: Warning: Error in <-: object 'output' not found),因为它缺少数据,但这解决了您的问题所带来的错误。

#Server.R
output$plot1 <- renderChartJSRadar({
  library(shiny)
  library(radarchart)
  ds<-subset(top_version,top_version$ageInd==input$select1)
  labs<-c('familiarity','favorability','consideration')
  scores<-list('Women'=c(nrow(ds[ds$familiarity==1 & ds$gender==2,])/nrow(ds[ds$gender==2,]),nrow(ds[ds$favorability==1 & ds$gender==2,])/nrow(ds[ds$gender==2,]),nrow(ds[ds$consideration==1 & ds$gender==2,])/nrow(ds[ds$gender==2,])),
               'Men'=c(nrow(ds[ds$familiarity==1 & ds$gender==1,])/nrow(ds[ds$gender==1,]),nrow(ds[ds$favorability==1 & ds$gender==1,])/nrow(ds[ds$gender==1,]),nrow(ds[ds$consideration==1 & ds$gender==1,])/nrow(ds[ds$gender==1,])))
  chartJSRadar(scores=scores, labs=labs,showToolTipLabel = T)
})

#ui.R
require(shiny)
library(radarchart)
column(width = 12,
       chartJSRadarOutput("plot1", width = "300", height = "100"))