簡體   English   中英

由於無法定位數據幀,本地工作的 Shiny 應用程序無法部署在 Shinyapps.io 中

[英]Shiny app that works locally cannot be deployed in shinyapps.io because of not being able to locate the dataframe

我創建了一個運行良好的閃亮應用程序,但是當我嘗試將它部署到Shinyapps.io 時,出現以下錯誤。 Error in value[[3L]](cond) : object 'all2' not found 為什么它找不到all2 我的原始文件是一個 excel 文件,我已將其存儲在我的工作目錄中並將其上傳到 rstudio

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(visNetwork)
library(shinyWidgets)
library(igraph)

shinyApp(
  ui = dashboardPagePlus(
    header = dashboardHeaderPlus(title = "Network Viz."
      
    ),
    sidebar = dashboardSidebar(
      pickerInput(
        inputId = "ctype"
        ,
        label = "Select Country" 
        ,
        choices = unique(all2$Country)
        ,
        selected = unique(all2$Country)[1],
        multiple = T,options = list(`actions-box` = TRUE)
        
      ),
      uiOutput("lang"),
      uiOutput("top")
      
    ),
    body = dashboardBody(#This hides the temporary warning messages while the plots are being created
      tags$style(type="text/css",
                 ".shiny-output-error { visibility: hidden; }",
                 ".shiny-output-error:before { visibility: hidden; }"
      ),
      visNetworkOutput("network")
    )
    
  ),
  server = function(input, output) { 
    ID<-c(1,2,3,4)
    Name<-c("j","dd","ff","fcf")
    Language<-c("en","fr","gr","gh")
    Country<-c("EN","FR","GR","GRE")
    Topic<-c("sc","sc","ghgf","vb")
    Follow<-c(34,56,76,76)
    Social<-c("Facebook","Facebook","Twitter","Twitter")
    all2<-data.frame(ID,Name,Language,Country,Topic,Follow,Social)
    dtnew<-reactive({
      new<-subset(all2, Country %in% input$ctype)
      
    })
    
    output$lang<-renderUI({
      pickerInput(
        inputId = "l1",
        label = "Select Language",
        choices = unique(dtnew()$Language),
        multiple = TRUE,
        selected = unique(dtnew()$Language)[1],
        
        options = list(`actions-box` = TRUE)
      )
    })
    output$top<-renderUI({
      pickerInput(
        inputId = "t1",
        label = "Select Topic",
        choices = unique(dtnew()$Topic),
        multiple = TRUE,
        selected = unique(dtnew()$Topic)[1],
        
        options = list(`actions-box` = TRUE)
      )
    })
    dtnew2<-reactive({
      new2<-subset(all2, Country %in% input$ctype&Language%in% input$l1&Topic%in% input$t1)
      
    })
    output$network <- renderVisNetwork({
        nodes<-dtnew2()
        nodes<-nodes[,-c(3,4)]
        nodes<-nodes[,-4]
        colnames(nodes)<-c("id","label","group","Platform")
        nodes$value<-nodes$id
        
        id<-c(nrow(nodes)+1,nrow(nodes)+2)
        label<-unique(nodes$Platform)
        group<-c("Social","Social")
        Platform<-unique(nodes$Platform)
        value<-c(nrow(nodes)+1,nrow(nodes)+2)
        
        
        ft<-data.frame(id,label,group,Platform,value)
        
        nodes<-rbind(nodes,ft)
        
        nodes<-nodes[!duplicated(nodes[2]),]
        nodes<-nodes[,-4]
        nodes$id <- nodes$label
        nodes$value <- seq.int(nrow(nodes))
        nodes$title<-paste0("<p>","Name:",nodes$label,"<br>","Group:",nodes$group,"</p>")
        edges<-dtnew2()
        edges<-edges[,c(2,6,7)]
        colnames(edges)<-c("from","value","to")
        edges$title<-edges$value
        
        
        
        visNetwork(nodes, edges, height = "500px", width = "100%") %>% 
          visOptions(highlightNearest = list(enabled = T, hover = T),nodesIdSelection = T) %>%
          visLayout(randomSeed = 123)%>%
          visInteraction(navigationButtons = TRUE)%>%
          visIgraphLayout() 
      
      
      
    })
    }
)

在此處輸入圖片說明

好的,我發現它我必須放置

ID<-c(1,2,3,4)
    Name<-c("j","dd","ff","fcf")
    Language<-c("en","fr","gr","gh")
    Country<-c("EN","FR","GR","GRE")
    Topic<-c("sc","sc","ghgf","vb")
    Follow<-c(34,56,76,76)
    Social<-c("Facebook","Facebook","Twitter","Twitter")
    all2<-data.frame(ID,Name,Language,Country,Topic,Follow,Social) 

shinyApp()之前

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM