-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
392 additions
and
2,382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# Install ZeroMQ | ||
sudo apt-get update -y | ||
sudo apt-get install libzmq3-dev -y | ||
|
||
# Setup bash to allow conda to run | ||
conda init bash && conda install -y ipykernel | ||
|
||
# Allow JupyterLab and IRkernel ro run R workbook | ||
R -e "install.packages('IRkernel')" | ||
R -e "IRkernel::installspec()" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"id": "88b29033-79a1-40f1-a755-8f10e67f3442", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"Installing package into ‘/usr/local/lib/R/site-library’\n", | ||
"(as ‘lib’ is unspecified)\n", | ||
"\n", | ||
"Installing package into ‘/usr/local/lib/R/site-library’\n", | ||
"(as ‘lib’ is unspecified)\n", | ||
"\n", | ||
"Installing package into ‘/usr/local/lib/R/site-library’\n", | ||
"(as ‘lib’ is unspecified)\n", | ||
"\n", | ||
"Installing package into ‘/usr/local/lib/R/site-library’\n", | ||
"(as ‘lib’ is unspecified)\n", | ||
"\n", | ||
"Installing package into ‘/usr/local/lib/R/site-library’\n", | ||
"(as ‘lib’ is unspecified)\n", | ||
"\n", | ||
"also installing the dependencies ‘colorspace’, ‘farver’, ‘labeling’, ‘munsell’, ‘RColorBrewer’, ‘viridisLite’, ‘gtable’, ‘isoband’, ‘scales’\n", | ||
"\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"install.packages(\"shinylive\")\n", | ||
"install.packages(\"shiny\")\n", | ||
"install.packages(\"shinyWidgets\")\n", | ||
"install.packages(\"dplyr\")\n", | ||
"install.packages(\"ggplot2\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "e03329ba-510e-4f00-bd20-6ada312e5d0d", | ||
"metadata": {}, | ||
"source": [ | ||
"---\n", | ||
"title: \"Template for r-shinylive Quarto document (Covid Example)\"\n", | ||
"format:\n", | ||
" html:\n", | ||
" resources: \n", | ||
" - shinylive-sw.js\n", | ||
"filters:\n", | ||
" - shinylive\n", | ||
"---" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"id": "09f6b537-b184-4ea6-b9b9-190f96207cdb", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"options(timeout = 6000)\n", | ||
"library(shiny)\n", | ||
"library(dplyr)\n", | ||
"library(ggplot2)\n", | ||
"library(shinyWidgets)\n", | ||
"\n", | ||
"# Download real COVID data for Washington state counties from the New York Times GitHub repo\n", | ||
"covid_url <- \"https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv\"\n", | ||
"covid_data <- read.csv(covid_url)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"id": "0a03f7b5-18cf-4df3-98b7-657cd171731e", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"\n", | ||
"Listening on http://127.0.0.1:7477\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"\n", | ||
"# Filter for Washington state and prepare the data\n", | ||
"washington_covid_data <- covid_data %>%\n", | ||
" filter(state == \"Washington\") %>%\n", | ||
" select(date, county, cases) %>%\n", | ||
" mutate(year_month = format(as.Date(date), \"%Y%m\")) # Create year_month column\n", | ||
"\n", | ||
"# Create a vector of unique year_month values from the dataset\n", | ||
"valid_year_months <- sort(unique(washington_covid_data$year_month))\n", | ||
"valid_year_months_index <- seq_along(valid_year_months)\n", | ||
"\n", | ||
"# Define the UI\n", | ||
"ui <- fluidPage(\n", | ||
" titlePanel(\"COVID Case Counts by Month-Year in Washington Counties\"),\n", | ||
" \n", | ||
" # Use fluidRow to place the slider at the top, spanning the entire page width\n", | ||
" fluidRow(\n", | ||
" column(12, # 12 columns to span full width\n", | ||
" sliderTextInput(\"selected_year_month\", \n", | ||
" \"Select Year and Month:\", \n", | ||
" choices = valid_year_months, # Use year-month values directly\n", | ||
" selected = \"202001\", # Start with the first year-month\n", | ||
" animate = animationOptions(interval = 1000, loop = FALSE))\n", | ||
" )\n", | ||
" ),\n", | ||
" \n", | ||
" # Main panel for the plot below the slider\n", | ||
" fluidRow(\n", | ||
" column(12, # This will also span the entire width\n", | ||
" plotOutput(\"histogramPlot\")\n", | ||
" )\n", | ||
" )\n", | ||
")\n", | ||
"\n", | ||
"\n", | ||
"# Define the server\n", | ||
"server <- function(input, output) {\n", | ||
" output$histogramPlot <- renderPlot({\n", | ||
" filtered_data <- washington_covid_data %>%\n", | ||
" filter(year_month == as.character(input$selected_year_month)) %>%\n", | ||
" group_by(county) %>%\n", | ||
" summarize(total_cases = max(cases, na.rm = TRUE)) # Get max case count for each county in the selected year_month\n", | ||
" \n", | ||
" ggplot(filtered_data, aes(x = county, y = total_cases)) +\n", | ||
" geom_bar(stat = \"identity\", fill = \"steelblue\") +\n", | ||
" labs(title = paste(\"COVID Cases in\", input$selected_year_month),\n", | ||
" x = \"County\", \n", | ||
" y = \"Total Case Count\") +\n", | ||
" theme_minimal() +\n", | ||
" theme(axis.text.x = element_text(angle = 45, hjust = 1))\n", | ||
" })\n", | ||
"}\n", | ||
"\n", | ||
"# Run the Shiny app\n", | ||
"shinyApp(ui = ui, server = server)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"id": "d050a599-2d6c-4338-9d6f-5ed08de7f98e", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"'/workspaces/quarto_demo/.devcontainer'" | ||
], | ||
"text/latex": [ | ||
"'/workspaces/quarto\\_demo/.devcontainer'" | ||
], | ||
"text/markdown": [ | ||
"'/workspaces/quarto_demo/.devcontainer'" | ||
], | ||
"text/plain": [ | ||
"[1] \"/workspaces/quarto_demo/.devcontainer\"" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"getwd()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "bf722ea2-9268-4a24-a275-4a3cf4c7c766", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "R", | ||
"language": "R", | ||
"name": "ir" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": "r", | ||
"file_extension": ".r", | ||
"mimetype": "text/x-r-source", | ||
"name": "R", | ||
"pygments_lexer": "r", | ||
"version": "4.4.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
File renamed without changes.
Oops, something went wrong.