Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/r_covidcast_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
defaults:
run:
working-directory: R-packages/covidcast/
strategy:
matrix:
r-version: [3.6]
r-version: [4.0]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up R ${{ matrix.r-version }}
uses: r-lib/actions/setup-r@v2
Expand Down
2 changes: 1 addition & 1 deletion R-packages/covidcast/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Description: Tools for Delphi's 'COVIDcast Epidata' API: data access, maps and
mobility data, typically updated daily and at the county level. All data
sources are documented at
<https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html>.
Depends: R (>= 3.5.0)
Depends: R (>= 4.0.0)
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Expand Down
2 changes: 1 addition & 1 deletion R-packages/covidcast/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# covidcast 0.5.3

To be released.
- Changes to be compatible with an upcoming release of ggplot2.

- Package vignettes have been adjusted so they do not make requests to the
COVIDcast API during CRAN check runs. This change only affects the package
Expand Down
98 changes: 73 additions & 25 deletions R-packages/covidcast/R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,32 @@ plot_choro <- function(x, time_value = NULL, include = c(), range,

geom_args$fill <- main_col
geom_args$data <- main_df
back_main_layer <- do.call(ggplot2::geom_sf, geom_args)
back_main_layer <- if (nrow(main_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}
geom_args$fill <- pr_col
geom_args$data <- pr_df
back_pr_layer <- do.call(ggplot2::geom_sf, geom_args)
back_pr_layer <- if (nrow(pr_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}
geom_args$fill <- hawaii_col
geom_args$data <- hawaii_df
back_hawaii_layer <- do.call(ggplot2::geom_sf, geom_args)
geom_args$fill <- alaska_col
back_hawaii_layer <- if (nrow(hawaii_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}
geom_args$data <- alaska_df
back_alaska_layer <- do.call(ggplot2::geom_sf, geom_args)
geom_args$fill <- alaska_col
back_alaska_layer <- if (nrow(alaska_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}

# Create the choropleth colors for counties
if (attributes(x)$metadata$geo_type == "county") {
Expand Down Expand Up @@ -438,16 +454,32 @@ plot_choro <- function(x, time_value = NULL, include = c(), range,

geom_args$fill <- main_col
geom_args$data <- main_df
main_layer <- do.call(ggplot2::geom_sf, geom_args)
main_layer <- if (nrow(main_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}
geom_args$fill <- pr_col
geom_args$data <- pr_df
pr_layer <- do.call(ggplot2::geom_sf, geom_args)
pr_layer <- if (nrow(pr_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}
geom_args$fill <- hawaii_col
geom_args$data <- hawaii_df
hawaii_layer <- do.call(ggplot2::geom_sf, geom_args)
hawaii_layer <- if (nrow(hawaii_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}
geom_args$fill <- alaska_col
geom_args$data <- alaska_df
alaska_layer <- do.call(ggplot2::geom_sf, geom_args)
alaska_layer <- if (nrow(alaska_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}
coord_layer <- do.call(ggplot2::coord_sf, coord_args)

# For continuous color scale, create a legend layer
Expand All @@ -467,9 +499,9 @@ plot_choro <- function(x, time_value = NULL, include = c(), range,
hidden_layer <- ggplot2::geom_point(ggplot2::aes(
x = .data$x, y = .data$x, color = .data$z),
data = hidden_df, alpha = 0)
guide <- ggplot2::guide_colorbar(title = NULL, horizontal = TRUE,
barheight = legend_height,
barwidth = legend_width)
guide <- ggplot2::guide_colorbar(title = NULL, direction = "horizontal",
barheight = legend_height,
barwidth = legend_width)
scale_layer <- ggplot2::scale_color_gradientn(colors = col_fun(d),
limits = range(d),
breaks = legend_breaks,
Expand All @@ -490,11 +522,11 @@ plot_choro <- function(x, time_value = NULL, include = c(), range,
ggplot2::aes(x = .data$x, y = .data$x, fill = .data$z),
data = hidden_df, alpha = 0
)
guide <- ggplot2::guide_legend(title = NULL, horizontal = TRUE, nrow = 1,
keyheight = legend_height,
keywidth = legend_width / n,
label.position = "bottom", label.hjust = 0,
override.aes = list(alpha = 1))
guide <- ggplot2::guide_legend(title = NULL, direction = "horizontal", nrow = 1,
keyheight = legend_height,
keywidth = legend_width / n,
label.position = "bottom", label.hjust = 0,
override.aes = list(alpha = 1))
scale_layer <- ggplot2::scale_fill_manual(values = col,
breaks = legend_breaks,
labels = legend_labels,
Expand Down Expand Up @@ -665,7 +697,7 @@ plot_bubble <- function(x, time_value = NULL, include = c(), range = NULL,

# Warn if there's any missing locations
if (any(map_df$back_color == missing_col)) {
warning("Bubble maps can be hard to read when there is missing data;",
warning("Bubble maps can be hard to read when there is missing data; ",
"the locations without data are filled in gray.")
}

Expand All @@ -683,16 +715,32 @@ plot_bubble <- function(x, time_value = NULL, include = c(), range = NULL,
geom_args$mapping <- ggplot2::aes(geometry=.data$geometry)
geom_args$fill <- main_df$back_color
geom_args$data <- main_df
main_layer <- do.call(ggplot2::geom_sf, geom_args)
main_layer <- if (nrow(main_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}
geom_args$fill <- pr_df$back_color
geom_args$data <- pr_df
pr_layer <- do.call(ggplot2::geom_sf, geom_args)
geom_args$fill <- hawaii_df$back_color
pr_layer <- if (nrow(pr_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}
geom_args$data <- hawaii_df
hawaii_layer <- do.call(ggplot2::geom_sf, geom_args)
geom_args$fill <- alaska_df$back_color
geom_args$fill <- hawaii_df$back_color
hawaii_layer <- if (nrow(hawaii_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}
geom_args$data <- alaska_df
alaska_layer <- do.call(ggplot2::geom_sf, geom_args)
geom_args$fill <- alaska_df$back_color
alaska_layer <- if (nrow(alaska_df) > 0) {
do.call(ggplot2::geom_sf, geom_args)
} else {
ggplot2::geom_blank()
}

# Change geometry to centroids
# Use centroid coordinates for plotting bubbles
Expand Down Expand Up @@ -733,7 +781,7 @@ plot_bubble <- function(x, time_value = NULL, include = c(), range = NULL,

# Create the scale layer
labels <- round(breaks, legend_digits)
guide <- ggplot2::guide_legend(title = NULL, horizontal = TRUE, nrow = 1)
guide <- ggplot2::guide_legend(title = NULL, direction = "horizontal", nrow = 1)
scale_layer <- ggplot2::scale_size_manual(values = sizes, breaks = breaks,
labels = labels, drop = FALSE,
guide = guide)
Expand Down
Binary file modified R-packages/covidcast/inst/shapefiles/county.geojson.bz2
Binary file not shown.
Loading