Hi all,
I published my first shiny app yesterday that worked great until I tried to update the data file today. Now I get an error when I republish - 'The application failed to start (exited with code 1)'.
I thought it was a library/package issue based on the log, but I can't figure it out. Any help would be appreciated. Thanks.
Here is the log from shinyapps.io
2022-11-19T23:22:42.830964+00:00 shinyapps[7674988]: Function found when exporting methods from the namespace ‘raster’ which is not S4 generic: ‘update’
2022-11-19T23:22:42.830971+00:00 shinyapps[7674988]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
2022-11-19T23:22:42.830977+00:00 shinyapps[7674988]: Execution halted
2022-11-19T23:22:42.830980+00:00 shinyapps[7674988]: Shiny application exiting ...
2022-11-19T23:22:43.829757+00:00 shinyapps[7674988]: Running on host: 1354eb3b4c93
2022-11-19T23:22:43.829795+00:00 shinyapps[7674988]: Server version: 2022.09.0
2022-11-19T23:22:43.829812+00:00 shinyapps[7674988]: LANG: C.UTF-8
2022-11-19T23:22:43.829816+00:00 shinyapps[7674988]: Working directory: /srv/connect/apps/winter_bison_movements
2022-11-19T23:22:43.830084+00:00 shinyapps[7674988]: Running content using the current R environment
2022-11-19T23:22:43.836352+00:00 shinyapps[7674988]: R version: 4.2.1
2022-11-19T23:22:43.836365+00:00 shinyapps[7674988]: shiny version: 1.7.3
2022-11-19T23:22:43.836368+00:00 shinyapps[7674988]: httpuv version: 1.6.6
2022-11-19T23:22:43.836377+00:00 shinyapps[7674988]: rmarkdown version: 2.17
2022-11-19T23:22:43.836408+00:00 shinyapps[7674988]: knitr version: 1.40
2022-11-19T23:22:43.836412+00:00 shinyapps[7674988]: jsonlite version: 1.8.2
2022-11-19T23:22:43.836415+00:00 shinyapps[7674988]: RJSONIO version: (none)
2022-11-19T23:22:43.836447+00:00 shinyapps[7674988]: htmltools version: 0.5.3
2022-11-19T23:22:43.836457+00:00 shinyapps[7674988]: reticulate version: (none)
2022-11-19T23:22:43.836768+00:00 shinyapps[7674988]: Using pandoc: /opt/connect/ext/pandoc/2.16
2022-11-19T23:22:44.212549+00:00 shinyapps[7674988]: Starting R with process ID: '46'
2022-11-19T23:22:44.212907+00:00 shinyapps[7674988]: Shiny application starting ...
2022-11-19T23:22:50.320228+00:00 shinyapps[7674988]: Error in value[3L] : package or namespace load failed for ‘tmap’:
2022-11-19T23:22:50.320270+00:00 shinyapps[7674988]: Function found when exporting methods from the namespace ‘raster’ which is not S4 generic: ‘update’
2022-11-19T23:22:50.320275+00:00 shinyapps[7674988]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
2022-11-19T23:22:50.320279+00:00 shinyapps[7674988]: Execution halted
2022-11-19T23:22:50.320283+00:00 shinyapps[7674988]: Shiny application exiting ...
Here is my code:
setup -----------------------------------------
library(shiny)
library(shinyWidgets)
library(tmap)
library(sf)
library(lubridate)
library(tidyverse)
shapefiles <-
list(boundary = st_read('data/shapefiles/boundary.shp'),
north = st_read('data/shapefiles/north.shp')) %>%
set_names(
names(.) %>%
tolower())
spat_data <-
read_csv('data/move.csv') %>%
rename(lat = GPS.Latitude,
long = GPS.Longitude) %>%
st_as_sf(
coords = c('long', 'lat'),
crs = st_crs(4326)) %>%
st_transform(crs =
st_crs(shapefiles$boundary)) %>%
mutate(date =
as.Date(rtime)) %>%
set_names(
names(.) %>%
tolower())
ui --------------------------------------------
ui <-
fluidPage(
titlePanel('Movements'),
sidebarPanel(
pickerInput(
inputId = 'id_select',
label = 'ID:',
choices = unique(spat_data$id),
selected = unique(spat_data$id),
options = list('actions-box' = TRUE),
multiple = TRUE
),
sliderInput(
inputId = 'dates_slider',
label = 'Date',
min = as.Date('2022-10-01'),
max = as.Date(max(spat_data$date)),
value = c(
as.Date(max(spat_data$date)) - 7,
as.Date(max(spat_data$date))),
dragRange = TRUE,
animate = animationOptions(interval = 200),
timeFormat = '%F')
),
mainPanel(
tmapOutput(outputId = 'movements_map')
)
)
server ----------------------------------------
server <-
function(input, output, session) {
movement_data <-
reactive({
spat_data %>%
filter(id %in% input$id_select,
date >= input$dates_slider[1],
date <= input$dates_slider[2]) %>%
group_by(id) %>%
filter(n() > 1) %>%
summarise(do_union = FALSE) %>%
st_cast('LINESTRING')
})
output$movements_map <-
renderTmap({
tm_shape(shapefiles$boundary,
name = 'boundary') +
tm_polygons(alpha = 0,
lwd = 2) +
tm_basemap(
c('Esri.WorldTopoMap',
'Esri.WorldImagery')) +
tm_view(
bbox = shapefiles$boundary) +
spat_data %>%
group_by(id) %>%
summarise(do_union = FALSE) %>%
st_cast('LINESTRING') %>%
tm_shape(name = 'Trajectory') +
tm_lines(col = 'id',
legend.col.show = FALSE,
lwd = 1.5,
style = 'cat',
palette = 'plasma',
popup.vars = c('id'),
zindex = 402)
})
observe({
tmapProxy('movements_map', session, {
if(!is.null(input$id_select)) {
tm_remove_layer(402) +
movement_data() %>%
tm_shape(name = 'Trajectory') +
tm_lines(col = 'id',
legend.col.show = FALSE,
lwd = 1.5,
style = 'cat',
palette = 'plasma',
popup.vars = c('id'),
zindex = 402,
interactive = FALSE)
} else {
tm_remove_layer(402)
}
})
})
}