Skip to content

Commit dc7595d

Browse files
committed
Merge branch 'update-ci' into test-saf
2 parents 8ec2616 + 945c083 commit dc7595d

File tree

16 files changed

+283
-140
lines changed

16 files changed

+283
-140
lines changed

.github/workflows/python_ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Python Lint and Testing
55

66
on:
77
push:
8-
branches: [ main ]
8+
branches: [ main, r-pkg-devel ]
99
pull_request:
10-
branches: [ main ]
10+
branches: [ main, r-pkg-devel ]
1111

1212
jobs:
1313
build:

.github/workflows/r_ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ name: R
1010

1111
on:
1212
push:
13-
branches: [ main ]
13+
branches: [ main, r-pkg-devel ]
1414
pull_request:
15-
branches: [ main ]
15+
branches: [ main, r-pkg-devel ]
1616

1717
jobs:
1818
build:
@@ -27,7 +27,7 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@v2
2929
- name: Set up R ${{ matrix.r-version }}
30-
uses: r-lib/actions/setup-r@ffe45a39586f073cc2e9af79c4ba563b657dc6e3
30+
uses: r-lib/actions/setup-r@v1
3131
with:
3232
r-version: ${{ matrix.r-version }}
3333
- name: Install libcurl
@@ -36,7 +36,7 @@ jobs:
3636
uses: actions/cache@v2
3737
with:
3838
path: ${{ env.R_LIBS_USER }}
39-
key: ${{ runner.os }}-r-1-
39+
key: ${{ runner.os }}-r-2-
4040
- name: Install dependencies
4141
run: |
4242
install.packages(c("remotes", "rcmdcheck"))

R-packages/covidcast/DEVELOP.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# covidcast development guide
22

3+
We follow a Git Flow model for development. The `main` branch is for the
4+
"release" version of the package, since changes on `main` are immediately
5+
available for installation and immediately appear on the documentation website.
6+
New features are instead developed on the `r-pkg-devel` branch so they can be
7+
beta-tested before release.
8+
9+
To make a change to the package, pull the latest version of `r-pkg-devel` and
10+
make a branch starting from there. When you open a pull request, set the base
11+
branch to be `r-pkg-devel`, *not* `main`.
12+
313
A short checklist for submitting pull requests:
414

515
1. Run the unit tests with `devtools::test()` and ensure they pass.
@@ -10,8 +20,8 @@ A short checklist for submitting pull requests:
1020
3. If you changed any documentation, rebuild the documentation with
1121
`devtools::document()` and then `pkgdown::build_site()`. (This can be slow,
1222
because our vignettes take a long time to build.)
13-
4. Submit the pull request and see if the CI can also successfully run the
14-
tests.
23+
4. Submit the pull request, setting the base branch to `r-pkg-devel`, and see if
24+
the CI can also successfully run the tests.
1525

1626
## Unit tests
1727

@@ -78,3 +88,20 @@ After changing a vignette or documentation, you'll need to rebuild the
7888
documentation. Use `devtools::document()` to do this. Then
7989
`pkgdown::build_site(".")` (from within the package directory) will rebuild the
8090
HTML documentation site.
91+
92+
## Release checklist
93+
94+
To release a new public version of the package, copy the template below into a
95+
new GitHub Issue and check off the items one at a time.
96+
97+
```
98+
- [ ] Increment the version number in `DESCRIPTION`
99+
- [ ] Update `NEWS.md` to describe all new features, bug fixes, and breaking changes since the last version
100+
- [ ] Run `devtools::check()` and ensure there are no errors.
101+
- [ ] Run `devtools::document()` and then `pkgdown::build_site()`.
102+
- [ ] Browse the generated documentation site and ensure there are no problems.
103+
- [ ] Commit the updated HTML to `r-pkg-devel`. Make sure you don't miss any new plot files!
104+
- [ ] Open a pull request to merge `r-pkg-devel` to `main` and request review.
105+
```
106+
107+
Once the pull request is merged, the new version is live.

R-packages/covidcast/NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ export(covidcast_meta)
1717
export(covidcast_signal)
1818
export(covidcast_signals)
1919
export(covidcast_wider)
20+
export(earliest_issue)
2021
export(fips_to_abbr)
2122
export(fips_to_name)
23+
export(latest_issue)
2224
export(name_to_abbr)
2325
export(name_to_cbsa)
2426
export(name_to_fips)

R-packages/covidcast/NEWS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# covidcast 0.4.0
2+
3+
Released TODO DATE.
4+
5+
## Major changes
6+
7+
- The new `latest_issue()` and `earliest_issue()` functions make it easy to
8+
filter data frames with multiple issues of each observation, obtaining only
9+
the latest or earliest issue of each.
10+
11+
112
# covidcast 0.3.1
213

314
Released October 31, 2020.

R-packages/covidcast/R/cor.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#'
33
#' Computes correlations between two `covidcast_signal` data frames, allowing
44
#' for slicing by geo location, or by time. (Only the latest issue from each
5-
#' data frame are used for correlations.) See the [correlations
5+
#' data frame is used for correlations.) See the [correlations
66
#' vignette](https://cmu-delphi.github.io/covidcast/covidcastR/articles/correlation-utils.html)
77
#' for examples.
88
#'

R-packages/covidcast/R/utils.R

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
1-
#' Fetch only the latest issue for each observation in a data frame
2-
#'
3-
#' Since `covidcast_signal()` can, with the right options, return multiple
4-
#' issues for a single observation in a single geo, we may want only the most
5-
#' recent for plotting, mapping, or other purposes.
6-
#'
7-
#' @param df A `covidcast_signal` data frame
8-
#' @return The same `covidcast_signal` data frame, but with only the latest
9-
#' issue of every observation
1+
#' Fetch the latest or earliest issue for each observation
2+
#'
3+
#' The data returned from `covidcast_signal()` or `covidcast_signals()` can, if
4+
#' called with the `issues` argument, contain multiple issues for a single
5+
#' observation in a single location. These functions filter the data frame to
6+
#' contain only the earliest issue or only the latest issue.
7+
#'
8+
#' @param df A `covidcast_signal` or `covidcast_signal_long` data frame, such as
9+
#' returned from `covidcast_signal()` or the "long" format of
10+
#' `aggregate_signals()`.
11+
#' @return A data frame in the same form, but with only the earliest or latest
12+
#' issue of every observation. Note that these functions sort the data frame
13+
#' as part of their filtering, so the output data frame rows may be in a
14+
#' different order.
1015
#' @importFrom rlang .data
11-
#' @keywords internal
16+
#' @export
1217
latest_issue <- function(df) {
13-
# Save the attributes, since grouping overwrites them
14-
attrs <- attributes(df)
15-
attrs <- attrs[!(names(attrs) %in% c("row.names", "names"))]
16-
17-
df <- df %>%
18-
dplyr::arrange(dplyr::desc(.data$issue)) %>%
19-
dplyr::distinct(.data$geo_value, .data$time_value,
20-
.keep_all = TRUE)
21-
22-
attributes(df) <- c(attributes(df), attrs)
23-
24-
return(df)
18+
return(first_or_last_issue(df, TRUE))
2519
}
2620

27-
#' Fetch only the earliest issue for each observation in a data frame
28-
#'
29-
#' Since `covidcast_signal()` can, with the right options, return multiple
30-
#' issues for a single observation in a single geo, we may want only the most
31-
#' recent for plotting, mapping, or other purposes.
32-
#'
33-
#' @param df A `covidcast_signal` data frame
34-
#' @return The same `covidcast_signal` data frame, but with only the earliest
35-
#' issue of every observation
36-
#' @importFrom rlang .data
37-
#' @keywords internal
21+
#' @rdname latest_issue
22+
#' @export
3823
earliest_issue <- function(df) {
39-
# Save the attributes, since grouping overwrites them
24+
return(first_or_last_issue(df, FALSE))
25+
}
26+
27+
# Helper to do either first or last issue.
28+
first_or_last_issue <- function(df, latest) {
29+
if (!inherits(df, c("covidcast_signal", "covidcast_signal_long"))) {
30+
stop("`df` must be a `covidcast_signal` or `covidcast_signal_long` data frame")
31+
}
32+
33+
# Save the attributes, such as metadata, since dplyr drops them
4034
attrs <- attributes(df)
4135
attrs <- attrs[!(names(attrs) %in% c("row.names", "names"))]
4236

37+
issue_sort <- function(df) {
38+
if (latest) {
39+
dplyr::arrange(df, dplyr::desc(.data$issue))
40+
} else {
41+
dplyr::arrange(df, .data$issue)
42+
}
43+
}
44+
4345
df <- df %>%
44-
dplyr::arrange(.data$issue) %>%
45-
dplyr::distinct(.data$geo_value, .data$time_value,
46-
.keep_all = TRUE)
46+
issue_sort() %>%
47+
dplyr::distinct(.data$data_source, .data$signal, .data$geo_value,
48+
.data$time_value, .keep_all = TRUE)
4749

4850
attributes(df) <- c(attributes(df), attrs)
4951

R-packages/covidcast/_pkgdown.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ reference:
4141
- print.covidcast_meta
4242
- summary.covidcast_signal
4343
- summary.covidcast_meta
44-
- title: Wrangle and correlate multiple signals
45-
desc: Calculate correlations, aggregate signals, and move between aggregated data formats
44+
- title: Wrangle and correlate signals
45+
desc: Calculate correlations, aggregate multiple signals, and move between aggregated data formats
4646
- contents:
4747
- covidcast_cor
48+
- latest_issue
49+
- earliest_issue
4850
- aggregate_signals
4951
- covidcast_longer
5052
- title: Geographic utilities

R-packages/covidcast/man/covidcast_cor.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

R-packages/covidcast/man/earliest_issue.Rd

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)