|
| 1 | +--- |
| 2 | +title: "nsf report 2024" |
| 3 | +format: |
| 4 | + html: |
| 5 | + theme: default |
| 6 | + toc: true |
| 7 | + number-sections: true |
| 8 | +--- |
| 9 | + |
| 10 | +```{r} |
| 11 | +# Load necessary libraries |
| 12 | +library(ggplot2) |
| 13 | +library(rnaturalearth) |
| 14 | +library(rnaturalearthdata) |
| 15 | +library(dplyr) |
| 16 | +
|
| 17 | +# Get world data |
| 18 | +world <- ne_countries(scale = "medium", returnclass = "sf") |
| 19 | +
|
| 20 | +# Data frame with country names and counts |
| 21 | +data <- data.frame( |
| 22 | + name = c("United States of America", "Brazil", "Germany", "Canada", "Nigeria", |
| 23 | + "Australia", "Peru", "Israel", "United Kingdom", "Panama", |
| 24 | + "Saudi Arabia", "Kenya", "Japan", "Nepal", "Spain", |
| 25 | + "Sweden", "Czech Republic", "Vietnam"), |
| 26 | + count = c(252, 6, 5, 5, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) |
| 27 | +) |
| 28 | +
|
| 29 | +# Join this data with the world map data |
| 30 | +world_data <- left_join(world, data, by = "name") |
| 31 | +
|
| 32 | +# Plot |
| 33 | +# Plot with adjusted scale |
| 34 | +countries_plot <- ggplot(data = world_data) + |
| 35 | + geom_sf(aes(fill = count), color = "white", size = 0.25) + |
| 36 | + scale_fill_gradient(low = "lightblue", high = "darkblue", |
| 37 | + limits = c(0, 252), |
| 38 | + breaks = c(1, 50, 100, 252), |
| 39 | + na.value = "grey90", name = "Users", |
| 40 | + labels = scales::comma) + |
| 41 | + #labs(title = "ESIIL Cyverse users per country") + |
| 42 | + theme_minimal() + |
| 43 | + theme(legend.position = "right", |
| 44 | + plot.title = element_text(hjust = 0.5)) |
| 45 | +
|
| 46 | +ggsave(countries_plot, file="countries_plot.png", dpi=600) |
| 47 | +
|
| 48 | +``` |
| 49 | + |
| 50 | + |
| 51 | +```{r} |
| 52 | +# Load necessary libraries |
| 53 | +library(ggplot2) |
| 54 | +library(dplyr) |
| 55 | +library(sf) |
| 56 | +library(rnaturalearth) |
| 57 | +library(rnaturalearthdata) |
| 58 | +
|
| 59 | +# Get U.S. states and Canadian provinces data |
| 60 | +states <- ne_states(country = "united states of america", returnclass = "sf") |
| 61 | +provinces <- ne_states(country = "canada", returnclass = "sf") |
| 62 | +
|
| 63 | +# Combine U.S. states and Canadian provinces |
| 64 | +north_america_map <- rbind(states, provinces) |
| 65 | +
|
| 66 | +# Data frame with regions and counts |
| 67 | +data <- data.frame( |
| 68 | + region = c("colorado", "california", "florida", "south dakota", "arizona", |
| 69 | + "louisiana", "new york", "south carolina", "new mexico", "north carolina", |
| 70 | + "minnesota", "massachusetts", "connecticut", "oregon", "wisconsin", |
| 71 | + "maryland", "virginia", "pennsylvania", "texas", "michigan", "illinois", |
| 72 | + "ontario", "north dakota", "georgia", "new jersey", "utah", |
| 73 | + "missouri", "idaho", "montana", "maine", "new hampshire", "ohio", "nevada", |
| 74 | + "hawaii", "arkansas", "wyoming", "oklahoma", "tennessee", "washington", |
| 75 | + "alabama", "district of columbia", "kentucky", "indiana", "rhode island", "iowa", |
| 76 | + "quebec", "british columbia"), |
| 77 | + count = c(76, 20, 16, 13, 8, 8, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, |
| 78 | + 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) |
| 79 | +) |
| 80 | +
|
| 81 | +# Map data to region names |
| 82 | +north_america_map$region <- tolower(north_america_map$name) |
| 83 | +north_america_map <- left_join(north_america_map, data, by = "region") |
| 84 | +
|
| 85 | +# Filter out regions with no data |
| 86 | +filled_regions <- north_america_map[!is.na(north_america_map$count), ] |
| 87 | +
|
| 88 | +# Calculate the bounding box of the filled regions |
| 89 | +bbox <- st_bbox(filled_regions) |
| 90 | +
|
| 91 | +# Crop the original map based on the bounding box |
| 92 | +cropped_map <- st_crop(north_america_map, bbox) |
| 93 | +
|
| 94 | +# Plot the map, focusing only on regions with data |
| 95 | +states_plot <- ggplot(data = cropped_map) + |
| 96 | + geom_sf(aes(fill = count), color = "white", size = 0.25) + |
| 97 | + scale_fill_gradient(low = "lightblue", high = "darkblue", na.value = "grey90", name = "Users") + |
| 98 | + #labs(title = "ESIIL Cyverse users per state") + |
| 99 | + theme_minimal() + |
| 100 | + theme(legend.position = "right") |
| 101 | +
|
| 102 | +ggsave(states_plot, file="states_plot.png", dpi=600) |
| 103 | +
|
| 104 | +
|
| 105 | +``` |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +```{r} |
| 110 | +library(plotly) |
| 111 | +
|
| 112 | +# Define tasks and their assumed start and end dates |
| 113 | +tasks <- data.frame( |
| 114 | + Task = c("CI User Needs Assessment", "Write new draft", "IRB approval", "Send to community", |
| 115 | + "analyze survey results", "Respond to User Needs Assessment", "CyVerse Workbench Integration", |
| 116 | + "Requirements & UI / UX design", "Code free large JupyterHub deployment", "Docker Registry", |
| 117 | + "Data library", "reorganize sections after summit", "write guidelines for community contribution", |
| 118 | + "guide a prototype community contribution into the library", "recruit community contributions", |
| 119 | + "write ESIIL contributions to the library", "Analytics library - Integrated workflows", |
| 120 | + "ESIIL community-driven high-level design", "Write code of conduct, authorship credits", |
| 121 | + "Write guidelines for community contribution", "Create ESIIL codes template", "Bring codes from Earth Lab's GitHub", |
| 122 | + "CI library", "Push-button terraform template", "WG-generated value-added information products", |
| 123 | + "Cycle ESIIL personnel through FOSS class", "Unified branding", "CI for Analytics / Data library", |
| 124 | + "ESIIL User Tracking Site", "Jim's Data Cube Pilot Project", "gdal set up on Jim's laptop", |
| 125 | + "Planning and Data Acquisition", "Data Cube Design and Setup", "Storage and Management", |
| 126 | + "Analysis and Visualization", "Security and Quality Assurance", "Scalability and Maintenance"), |
| 127 | + Start = seq(as.Date("2023-06-01"), length.out = 37, by = "15 days"), |
| 128 | + End = seq(as.Date("2023-07-01"), length.out = 37, by = "15 days"), |
| 129 | + Owner = rep(c("Ty", "Tyson, Ty, Cibele", "Tyson", "Erick", "Cibele", "Jim"), length.out = 37), |
| 130 | + Color = ifelse(seq(as.Date("2023-06-01"), length.out = 37, by = "15 days") < as.Date("2024-06-01"), 'rgb(0,123,255)', 'rgb(255,0,0)') |
| 131 | +) |
| 132 | +
|
| 133 | +# Create a Gantt chart using Plotly |
| 134 | +fig <- plot_ly() |
| 135 | +fig <- fig %>% add_trace( |
| 136 | + type = 'bar', |
| 137 | + x = as.numeric(difftime(tasks$End, tasks$Start, units = "days")), |
| 138 | + y = tasks$Task, |
| 139 | + base = as.numeric(difftime(tasks$Start, as.Date("2023-06-01"), units = "days")), |
| 140 | + orientation = 'h', |
| 141 | + marker = list(color = tasks$Color, line = list(color = 'rgb(255,255,255)', width = 2)) |
| 142 | +) |
| 143 | +
|
| 144 | +fig <- fig %>% layout( |
| 145 | + title = "Gantt Chart for ESIIL Year 2 Projects", |
| 146 | + paper_bgcolor='rgba(0,0,0,0)', # transparent background |
| 147 | + plot_bgcolor='rgba(0,0,0,0)', # transparent background |
| 148 | + xaxis = list( |
| 149 | + title = "Days from Start", |
| 150 | + showgrid = TRUE, |
| 151 | + tickvals = seq(0, 760, by = 30), |
| 152 | + ticktext = seq(as.Date("2023-06-01"), length.out = 26, by = "month") %>% format("%b %Y") |
| 153 | + ), |
| 154 | + yaxis = list(title = "") |
| 155 | +) |
| 156 | +
|
| 157 | +# Show the plot |
| 158 | +fig |
| 159 | +
|
| 160 | +# Save Plotly plot to HTML |
| 161 | +htmlwidgets::saveWidget(as_widget(fig), "temp_plot.html", selfcontained = TRUE) |
| 162 | +
|
| 163 | +# Use webshot to convert the HTML to PNG |
| 164 | +webshot::webshot("temp_plot.html", "gantt_chart.png", delay = 5) # delay may need adjustment |
| 165 | +
|
| 166 | +
|
| 167 | +``` |
| 168 | + |
0 commit comments