r - Shiny server deployment to shinyapps.io error -
i have issue deploying app shinyapps.io.
running deploy within rstudio (r 3.1.1/win64) following message:
preparing deploy application...done uploading application bundle...done deploying application: 20528... waiting task: 1656427 building: parsing manifest building: installing packages building: installing files building: pushing image: 54178 deploying: starting instances terminating: stopping old instances application deployed http://littlebig.shinyapps.io/crisis shinyapps deployment completed: http://littlebig.shinyapps.io/crisis
however, when launching app message saying "application failed start" following error message:
attaching package: ‘shiny’the following object masked _by_ ‘.globalenv’: tagserror in paste(tags$script(src = "__assets__/sockjs-0.3.min.js"), tags$script(src = "__assets__/shiny-server-pro.js"), : attempt apply non-functioncalls: local ... eval.parent -> eval -> eval -> eval -> eval -> pasteexecution halted
i'm lost problem - running app locally works without issues whatsoever.
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 api @ crisis.net."), h5("select tag in list see location of (up to) 500 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, = "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))}) })
httr imports jsonlite , stringr shouldn't need load those. haven't looked dependencies , masking, there great question/answer on here , defiantly matters if package imports or depends on other packages in terms of masking. i'd try changing libraries load in server.r to:
server.r
library(shiny) library(httr) # rest of code...
Comments
Post a Comment