2017-09-24 1 views
0

私のアプリはローカルで正常に動作します。私はそれと対話することができます。しかし、グローバルに展開すると、すぐに "Disconnected from Server"エラーがスローされます。私は数日間グーグルで行ってきたし、試してみる方法を知っているすべてを試しました。最初ローカルに読み込んでいるシャイニーアプリ、デプロイ時にサーバーから切断する

まず物事:私は私がすべてで光沢のあるログ内の情報はありません

  • を使用しています、私はすべてのパッケージを更新したパッケージ
  • の束を再インストール後、アンインストールしようとした

    • 。 "このアプリケーションは現在ログがありません。"
    • マイデータ(CSV)私は同じ問題に
    • を持つ続けただけで約200行に減少するとき、私は、設定を経て、スタートアップを変更するだけで17メガバイト(3列、1Mっぽい行)
    • ですタイムアウトを300に設定し、他の各設定を1つずつ体系的に変更しました。
    • ブラウザのJavaScriptログを最後まで読みました。彼らは(私はJavaScriptを知らないので)たぶん意味がありませんでしたが、何も目立っていませんでした。アプリ自体に

      Preparing to deploy application...DONE 
      Uploading bundle for application: 193997...DONE 
      Deploying bundle: 994423 for application: 193997 ... 
      Waiting for task: 489405538 
          building: Building image: 992534 
          building: Fetching packages 
          building: Installing packages 
          building: Installing files 
          building: Pushing image: 992534 
          deploying: Starting instances 
          rollforward: Activating new instances 
          terminating: Stopping old instances 
      Application successfully deployed to https://jesstme.shinyapps.io/shinynames/ 
      Deployment completed: https://jesstme.shinyapps.io/shinynames/ 
      

      リンク:

    • 私はファイルパス全体で私のデータをロードしておりません
    • 、ちょうど端部が

    私の「展開」RStudioにログイン

  • は、成功した展開を示し https://jesstme.shinyapps.io/shinynames/

    Serverコード:

    #set wd & environment---- 
    setwd("/Users/OldJess/Dropbox/R Stuff (Home)/ShinyNames") 
    
    #load packages------ 
    library(datasets) 
    library(ggplot2) 
    library(viridis) 
    library(ggthemes) 
    library(gridExtra) 
    library(dplyr) 
    library(rdrop2) 
    library(shiny) 
    library(devtools) 
    
    #base <- read.csv("data/NationalNamesBrief.csv", stringsAsFactors = FALSE,  row.names = NULL, na.strings = c("NA","","#MULTIVALUE")) 
    
    #temporary df for demonstration purposes 
    base <- structure(list(Name = c("Ellie", "Ellie", "Ellie", "Ellie", "Ellie", 
              "Ellie"), 
            Year = c(1880L, 1881L, 1882L, 1883L, 1883L, 1884L), 
            Gender = c("F", "F", "F", "F", "M", "F"), 
            Count = c(17L, 27L, 37L, 24L, 7L, 28L)), 
           .Names = c("Name", "Year", "Gender", "Count"), 
           row.names = c(NA, 6L), class = "data.frame") 
    
    #clean data---- 
    base$name <- tolower(base$Name) 
    base$MF <- as.factor(base$Gender) 
    
    #add ranking data by Year 
    base <- base %>% 
        group_by(Year) %>% 
        arrange(Year, desc(Count)) %>% 
        mutate(Rank = row_number()) 
    
    #add ranking data by Year AND Gender 
    base <- base %>% 
        group_by(Year, Gender) %>% 
        arrange(Year, desc(Count)) %>% 
        mutate(GenderRank = row_number()) 
    
    #create functions---- 
    #function to create line & heat charts 
    lineHeatCharts <- function(pickaname){ 
        pickanameLower <- tolower(pickaname) 
        subDf <- subset(base[base$name == pickanameLower,]) 
        heat <- ggplot(subDf, aes(x = Year, y = MF, fill = Count)) + 
        scale_fill_viridis(name = "", 
            option = "B", 
            limits = c(0, max(subDf$Count))) + 
        geom_tile(color = "white", size = 0) + 
        theme_tufte() + 
        theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1), 
         axis.ticks.x = element_blank()) + 
        scale_x_continuous(breaks = seq(min(subDf$Year), 
               max(subDf$Year), by = 5)) + 
        labs(x = "Year", y = "") 
        line <- ggplot(subDf, aes(x = Year, y = Count, fill = MF)) + 
    geom_line(aes(colour = factor(subDf$Gender)), size = 1.5) + 
    theme_tufte() + 
    theme(axis.text.x = element_blank(), 
         axis.ticks.x = element_blank()) + 
    scale_x_continuous(breaks = seq(min(subDf$Year), 
               max(subDf$Year), by = 5)) + 
    labs(x = "", y = "", color = "") 
        return(grid.arrange(line, heat, 
            ncol = 1, nrow = 2, 
            heights = c(5, 2), top = max(subDf$Name))) 
    } 
    
    # Define server logic 
    function(input, output) { 
    
        output$view <- renderPlot({ 
        lineHeatCharts(input$list) 
        }) 
    } 
    

    UIコード:

    library(shiny) 
    library(shinythemes) 
    
    # Define UI for dataset viewer application 
    fluidPage(theme = shinytheme("flatly"), 
    
        # Application title 
        titlePanel("First Names on U.S. Social Security Applications, 1880 - 2014"), 
    
        sidebarLayout(
        sidebarPanel(
         textInput(inputId = "list", label = "Enter a name:", value = "Ellie"), 
    
         helpText("Note: This page will take about 30 seconds to load the first  time you open it. Data are from US Social Security applications via data.gov. For privacy, only names with at least 5 babies per year are included. Errors in Social Security form submission, like incorrect sex, are not corrected. Names with special characters and spaces are not included."), 
    
        submitButton("Refresh View") 
    ), 
    
    mainPanel(
        h4(""), 
        plotOutput("view") 
        ) 
    ) 
    ) 
    
    +1

    アプリ全体を提供できますか? –

    +0

    @ PorkChop完了。 – jesstme

    答えて

    0

    それは二つの問題があった結局のところ:私は私のコードのsetwd()第二行を削除するために必要な 1) 2)光沢のあるログが機能しませんでした。

    私はGoogleのShinyフォーラムに投稿しました.RStudio担当者がログの問題を修正しました。ログが機能したら、私はエラーがsetwdへの私の試みを指摘したことがわかりました。それを削除し、問題は修正されました。私はこの問題がある時点で他の人を悩ませると確信しているので、この質問を残しておいてください。

    1

    はこれを試してみてください:

    #set wd & environment---- 
    #setwd("/Users/OldJess/Dropbox/R Stuff (Home)/ShinyNames") 
    
    #load packages------ 
    library(datasets) 
    library(ggplot2) 
    library(viridis) 
    library(ggthemes) 
    library(gridExtra) 
    library(dplyr) 
    library(shiny) 
    library(shinythemes) 
    
    #base <- read.csv("data/NationalNamesBrief.csv", stringsAsFactors = FALSE,  row.names = NULL, na.strings = c("NA","","#MULTIVALUE")) 
    
    #temporary df for demonstration purposes 
    base <- structure(list(Name = c("Ellie", "Ellie", "Ellie", "Ellie", "Ellie", "Ellie"), 
             Year = c(1880L, 1881L, 1882L, 1883L, 1883L, 1884L), 
             Gender = c("F", "F", "F", "F", "M", "F"), 
             Count = c(17L, 27L, 37L, 24L, 7L, 28L)), 
            .Names = c("Name", "Year", "Gender", "Count"), 
            row.names = c(NA, 6L), class = "data.frame") 
    
    #clean data---- 
    base$name <- tolower(base$Name) 
    base$MF <- as.factor(base$Gender) 
    
    #add ranking data by Year 
    base <- base %>% 
        group_by(Year) %>% 
        arrange(Year, desc(Count)) %>% 
        mutate(Rank = row_number()) 
    
    #add ranking data by Year AND Gender 
    base <- base %>% 
        group_by(Year, Gender) %>% 
        arrange(Year, desc(Count)) %>% 
        mutate(GenderRank = row_number()) 
    
    #create functions---- 
    #function to create line & heat charts 
    lineHeatCharts <- function(pickaname){ 
        pickanameLower <- tolower(pickaname) 
    
        if(!any(base$name %in% pickanameLower)){ 
        return() 
        } 
    
        subDf <- subset(base[base$name == pickanameLower,]) 
        heat <- ggplot(subDf, aes(x = Year, y = MF, fill = Count)) + 
        scale_fill_viridis(name = "", 
             option = "B", 
             limits = c(0, max(subDf$Count))) + 
        geom_tile(color = "white", size = 0) + 
        theme_tufte() + 
        theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1), 
          axis.ticks.x = element_blank()) + 
        scale_x_continuous(breaks = seq(min(subDf$Year), max(subDf$Year), by = 5)) + 
        labs(x = "Year", y = "") 
        line <- ggplot(subDf, aes(x = Year, y = Count, fill = MF)) + 
        geom_line(aes(colour = factor(subDf$Gender)), size = 1.5) + 
        theme_tufte() + 
        theme(axis.text.x = element_blank(), 
          axis.ticks.x = element_blank()) + 
        scale_x_continuous(breaks = seq(min(subDf$Year), 
                max(subDf$Year), by = 5)) + 
        labs(x = "", y = "", color = "") 
        return(grid.arrange(line, heat, ncol = 1, nrow = 2, heights = c(5, 2), top = max(subDf$Name))) 
    } 
    
    ui <- fluidPage(theme = shinytheme("flatly"), 
    
           # Application title 
           titlePanel("First Names on U.S. Social Security Applications, 1880 - 2014"), 
    
           sidebarLayout(
            sidebarPanel(
            textInput(inputId = "list", label = "Enter a name:", value = "Ellie"), 
    
            helpText("Note: This page will take about 30 seconds to load the first  time you open it. Data are from US Social Security applications via data.gov. For privacy, only names with at least 5 babies per year are included. Errors in Social Security form submission, like incorrect sex, are not corrected. Names with special characters and spaces are not included."), 
    
            submitButton("Refresh View") 
           ), 
            mainPanel(
            h4(""), 
            plotOutput("view") 
           ) 
           ) 
    ) 
    
    server <- function(input, output, session) { 
    
        output$view <- renderPlot({ 
        lineHeatCharts(input$list) 
        }) 
    } 
    
    shinyApp(ui, server) 
    

    enter image description here

    +0

    最後の行に加えて他にどのような変更を加えましたか? – jesstme

    +0

    'if(!any(base $ name%in%pickanameLower)){return()}'を追加しました。 –

    関連する問題