2014-09-21 162 views
0

我有一个应用程序部署到shinyapps.io的问题。闪亮的服务器部署到shinyapps.io错误

内RStudio运行部署(R 3.1.1/Win64上)我得到以下信息:

Preparing to deploy application...DONE 
Uploading application bundle...DONE 
Deploying application: 20528... 
Waiting for task: 1656427 
    building: Parsing manifest 
    building: Installing packages 
    building: Installing files 
    building: Pushing image: 54178 
    deploying: Starting instances 
    terminating: Stopping old instances 
Application successfully deployed to http://littlebig.shinyapps.io/crisis 
ShinyApps deployment completed: http://littlebig.shinyapps.io/crisis 

然而,启动应用程序时,我得到一个消息,说“应用程序未能启动”具有以下错误信息:

Attaching package: ‘shiny’The following object is masked _by_ ‘.GlobalEnv’: tagsError in paste(tags$script(src = "__assets__/sockjs-0.3.min.js"), tags$script(src = "__assets__/shiny-server-pro.js"), : attempt to apply non-functionCalls: local ... eval.parent -> eval -> eval -> eval -> eval -> pasteExecution halted 

我真的失去了什么问题 - 在本地运行应用程序没有任何问题。

ui.R:

library(shiny) 
shinyUI(pageWithSidebar(
    headerPanel("Crisis.Net"), 
    sidebarPanel(
    checkboxGroupInput("crisisTags", 
         label = h4("Tags"), 
         choices = list(
         "Air combat" = "air-combat", 
         "Armed conflict" = "armed-conflict", 
         "Suicide bombing" = "suicide-bombing", 
         "Torture" = "torture"), 
         selected = NULL) 
), 
    mainPanel(
    h4("This app pulls data from the api at crisis.net."), 
    h5("Select a tag in the list to see the location of the (up to) 500 most recent reported instances."), 
    htmlOutput("crisisMap") 
) 
)) 

server.R

library(httr) 
library(jsonlite) 
library(stringr) 
library(shiny) 

query.api <- function(path, ...) { 
    query <- list(...) 
    query <- query[!sapply(query, is.null)] 
    query$apikey <- "xxxxxxxxxxxxxxxxxxxxxxxx" 
    query.url <- list(
    scheme = "http", 
    hostname = "api.crisis.net", 
    port  = NULL, 
    path  = path, 
    query = query, 
    params = NULL, 
    fragment = NULL, 
    username = NULL, 
    password = NULL) 
    attr(query.url, "class") <- "url" 
    response <- GET(build_url(query.url)) 
    stop_for_status(response) 
    return(response) 
} 

crisisGetItems <- function(before = NULL, 
          after = NULL, 
          placeName = NULL, 
          location = NULL, 
          distance = NULL, 
          tags = NULL, 
          limit = NULL) { 

    if (!is.null(tags)) tags <- paste(tags, collapse = ",") 
    if (!is.null(location)) location <- paste(location, collapse = ",") 

    if (!is.null(before)) before <- format(before, "%Y-%m-%dT%H:%M:%S.000Z") 
    if (!is.null(after)) after <- format(after, "%Y-%m-%dT%H:%M:%S.000Z") 

    response <- query.api("item", 
         before = before, 
         after  = after, 
         placeName = placeName, 
         location = location, 
         distance = distance, 
         tags  = tags, 
         limit  = limit) 

    response.text <- content(response, as = "text", type = "application/json") 
    items <- fromJSON(response.text, flatten = TRUE) 

    lon <- unlist(sapply(items$data$geo.coords, function(x) ifelse(is.null(x), NA, x[1]))) 
    lat <- unlist(sapply(items$data$geo.coords, function(x) ifelse(is.null(x), NA, x[2]))) 

    getTags <- function(x, num) { 
    if (is.null(x)) { 
     NA 
    } else { 
     if (is.null(x$name[num])) { 
     NA 
     } else { 
     x$name[num] 
     } 
    } 
    } 

    items <- data.frame(
    tag1 = sapply(items$data$tags, getTags, 1), 
    tag2 = sapply(items$data$tags, getTags, 2), 
    tag3 = sapply(items$data$tags, getTags, 3), 
    longitude = lon, 
    latitude = lat, 
    src  = items$data$`source`, 
    src.url = items$data$fromURL 
) 

    getLatLon <- function(lat, lon) { 
    if (is.na(lon) || is.na(lat)) { 
     NA  
    } else { 
     paste(c(lat, lon), collapse = ":") 
    } 
    } 

    items$LatLon <- mapply(getLatLon, items$latitude, items$longitude) 
    return(items) 
} 

crisisItems <- subset(crisisGetItems(limit = 500), !is.na(LatLon)) 

shinyServer(function(input, output) { 

    output$crisisMap <- renderGvis({ 
    gvisMap(
     subset(crisisGetItems(tags = input$crisisTags, limit = 500), !is.na(LatLon)), 
     "LatLon", 
     "tag1", 
     options=list(showTip=TRUE, 
        showLine=TRUE, 
        enableScrollWheel=TRUE, 
        mapType='terrain', 
        useMapTypeControl=TRUE))}) 

}) 

回答

0

HTTR进口jsonlite和stringr所以你不应该需要加载的。我并没有深入研究依赖和掩饰,但是有一个很好的SO问题/答案HERE,如果一个软件包导入或依赖于其他软件包的屏蔽,这一点很重要。所以我想尝试改变你server.R加载库:

server.R

library(shiny) 
library(httr) 

# The rest of your code...
+0

非常感谢!它没有100%解决问题,因为我无意中省略了对'googleVis'的引用+我不得不将'fromJSON'显式引用为'jsonlite :: fromJSON',以使应用程序正常工作。尽管如此,让我有99%的路程,欢呼! – 17843 2014-09-23 20:18:44

+0

太好听了...祝你好运 – miles2know 2014-09-24 11:11:59