Skip to content

Commit

Permalink
Merge pull request #20 from CDCgov/dev
Browse files Browse the repository at this point in the history
Version Bump 0.1 -> 0.2
  • Loading branch information
beansrowning authored Mar 9, 2022
2 parents ba9ea11 + 5d06e0b commit 640c554
Show file tree
Hide file tree
Showing 72 changed files with 2,126 additions and 934 deletions.
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
^.*\.Rproj$
^\.Rproj\.user$
^.*\.github$
^_pkgdown\.yml$
^docs$
^pkgdown$
^\.github$
^codecov\.yml$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
35 changes: 35 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [ master, dev ]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-pandoc@v1

- uses: r-lib/actions/setup-r@v1
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
with:
extra-packages: pkgdown
needs: website

- name: Deploy package
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
3 changes: 3 additions & 0 deletions .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
extra-packages: rcmdcheck
cache-version: 2
- uses: r-lib/actions/check-r-package@v2
with:
args: '"--no-manual"'
error-on: '"error"'
# - name: Upload check results
# if: failure()
# uses: actions/upload-artifact@main
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
with:
extra-packages: covr

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.Rhistory
.RData
.Ruserdata
docs
101 changes: 0 additions & 101 deletions AMC_AU_COUNTRIES.csv

This file was deleted.

20 changes: 15 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
Package: SaviR
Type: Package
Title: ITF Analytics
Version: 0.1.0
Author: Authors@R: person("Randy", "Yee", email = "[email protected]", role = c("aut", "cre"))
Maintainer: Randy Yee <[email protected]>
Title: ITF Situational Awareness and Visualization
Version: 0.2.0
Authors@R: c(
person("Sean", "Browning", email = "[email protected]", role = c("aut", "cre")),
person("Kimberly", "Wong", email = "[email protected]", role = "aut"),
person("Nartlada", "Chantharojwong", email = "[email protected]", role = "aut"),
person("James", "Fuller", role = "aut"),
person("Dante", "Bugli", role = "ctb"),
person("Randy", "Yee", email = "[email protected]", role = "aut"))
Description: Data access and management of open-source COVID data for the production of analytic datasets.
License: Apache + file LICENSE
Imports:
Expand All @@ -25,6 +30,7 @@ Imports:
RcppRoll,
cachem,
data.table,
openxlsx,
magrittr,
memoise,
rgdal,
Expand All @@ -34,13 +40,17 @@ Imports:
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.2
Roxygen: list(markdown = TRUE)
Suggests:
rmarkdown,
htmltools,
tidyr,
webshot,
knitr,
vdiffr,
testthat (>= 3.0.0)
httr,
testthat (>= 3.0.0),
covr
Config/testthat/edition: 3
Depends:
R (>= 3.5.0)
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(calc_add_risk)
export(calc_vax_carryforward)
export(get_combined_table)
export(get_country_coords)
export(get_covid_df)
export(get_gdeltnews)
Expand All @@ -10,6 +12,7 @@ export(get_preferred_tests14)
export(get_testing)
export(get_testing_long)
export(get_vax)
export(get_vax_dates)
export(get_vax_manufacturers)
export(map_burden)
export(map_template)
Expand Down Expand Up @@ -47,6 +50,7 @@ importFrom(cachem,cache_mem)
importFrom(data.table,fread)
importFrom(magrittr,`%>%`)
importFrom(memoise,memoise)
importFrom(openxlsx,read.xlsx)
importFrom(purrr,set_names)
importFrom(rgdal,readOGR)
importFrom(sp,spTransform)
Expand Down
9 changes: 4 additions & 5 deletions R/calc_riskmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#' @title calc_add_risk
#' @description Calculate epi stats a generalized df input.
#' @param df Dataframe with id (iso3), date, new_cases, new_deaths, cumulative_cases, cumulative_deaths, AND population.
#' @param df Dataframe with id, date, new_cases, new_deaths, cumulative_cases, cumulative_deaths, AND population.
#'

#' @importFrom RcppRoll roll_mean
Expand All @@ -12,11 +12,10 @@
#' @examples
#' \dontrun{
#' df <- onetable %>%
#' right_join(get_covid_df() %>% select(-who_region), by = c("iso2code" = "country_code")) %>%
#' filter(!(country == "China" & source == "WHO"))
#'
#' right_join(get_covid_df(), by = c("iso2code")) %>%
#' filter(!(country == "China" & source == "WHO"))
#'
#' calc_add_risk(df)
#'
#' }
#'
calc_add_risk <- function(df) {
Expand Down
41 changes: 41 additions & 0 deletions R/calc_vax_carryforward.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#' @title Carry-Forward vaccination metrics to latest date
#'
#' @param df (data.frame) Source data frame containing vaccine metrics from [get_vax()]
#' @param ... (optional) (un-)quoted column names to carry forward. Overwrites standard variable set
#'
#' @return df with either columns in \code{...} carried forward, or default set
#' @section Notes:
#' By default, function carries forward the following (unless names are passed in \code{...}):
#' \itemize{
#' \item{total_vaccinations}{}
#' \item{people_vaccinated}{}
#' \item{people_fully_vaccinated}{}
#' \item{total_boosters}{}
#' \item{total_vaccinations_per_hundred}{}
#' \item{people_vaccinated_per_hundred}{}
#' \item{people_fully_vaccinated_per_hundred}{}
#' \item{total_boosters_per_hundred}{}
#' }
#' @export
calc_vax_carryforward <- function(df, ...) {
# Optionally specify vax cols by name if we want to be specific
vax_cols <- rlang::enquos(...)

# If not specified, just take standard set.
if (!length(vax_cols)) {
vaccine_col_str <- c(
"total_vaccinations", "people_vaccinated", "people_fully_vaccinated",
"total_boosters", "total_vaccinations_per_hundred", "people_vaccinated_per_hundred",
"people_fully_vaccinated_per_hundred", "total_boosters_per_hundred"
)

vax_cols <- lapply(vaccine_col_str, as.name)
}

df %>%
arrange(id, date) %>%
group_by(id) %>%
# Take any cols that
mutate_at(vars(!!!vax_cols), zoo::na.locf, na.rm = FALSE) %>%
ungroup()
}
Loading

0 comments on commit 640c554

Please sign in to comment.