Skip to content

Commit

Permalink
Testing serverless shiny forecast page using github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jevanilla committed Aug 9, 2024
1 parent 265c227 commit e003f6e
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
23 changes: 23 additions & 0 deletions .github/workflows/deploy-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Workflow derived from https://github.com/posit-dev/r-shinylive/tree/actions-v1/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# Basic example of a GitHub Actions workflow that builds a Shiny app and deploys
# it to GitHub Pages.
name: Deploy app to gh-pages

on:
# Manually trigger the workflow
workflow_dispatch:
# Trigger on push to `main` branch
push:
branches: ["main"]
# Trigger on pull request to all branches (but do not deploy to gh-pages)
pull_request:

jobs:
shinylive:
uses: posit-dev/r-shinylive/.github/workflows/deploy-app.yaml@actions-v1
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Maintainer: Johnathan Evanilla <[email protected]>
Author: Johnathan Evanilla <[email protected]>
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
47 changes: 47 additions & 0 deletions app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
### Interactive PSP Forecast Result Explorer ###

suppressPackageStartupMessages({
library(shiny)
library(leaflet)
library(dplyr)
library(readr)
})

current_forecast <- read_csv("https://github.com/BigelowLab/pspforecast/raw/master/inst/forecastdb/current_forecast.csv")

ui <- fluidPage(
titlePanel("Experimental Maine PSP 4-10 Day Forecast"),
mainPanel(
verticalLayout(
leafletOutput("current_forecast"))
)
)

server <- function(input, output) {

output$current_forecast <- renderLeaflet({
pal <- colorNumeric(c("dimgray","gold", "orange", "red"), 0:3)

leaflet() |>
setView(lng=-68.5,lat = 44, zoom = 7) |>
addTiles(group= "Default Background") |>
#addProviderTiles("Esri.NatGeoWorldMap") |>
addCircleMarkers(data=current_forecast,
lng = ~lon,
lat = ~lat,
popup = paste(sep= "<br>",
paste("<b> Location: <b>", current_forecast$name),
paste("<b> Location ID: <b>", current_forecast$location),
paste("<b> Forecast Window Start Date: <b>", current_forecast$forecast_start_date),
paste("<b> Forecast Window End Date: <b>", current_forecast$forecast_end_date),
paste("<b> Probability of Closure-level Toxicity: <b>", current_forecast$p_3, "%", sep="")),
color = ~pal(predicted_class)) |>
addLegend(position = "bottomright",
title = "Predicted Toxicity Class",
colors = c("dimgray", "gold", "orange", "red"),
labels = c("Low", "Medium", "High", "Closure-level"))
})
}

# Run the application
shinyApp(ui = ui, server = server)
8 changes: 8 additions & 0 deletions man/pspforecast.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e003f6e

Please sign in to comment.