Skip to content

Commit

Permalink
Merge pull request #305 from R4EPI/nb_outbreakWalk
Browse files Browse the repository at this point in the history
Nb outbreak walk
  • Loading branch information
aspina7 authored Sep 7, 2022
2 parents c8a4f8f + 2a97f7b commit 32f5d4e
Show file tree
Hide file tree
Showing 66 changed files with 8,859 additions and 482 deletions.
11 changes: 7 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Imports:
binom,
broom,
clipr,
cli,
dplyr (>= 0.8.0),
epitabulate (>= 0.0.0.9007),
epidict (>= 0.0.0.9001),
Expand All @@ -68,6 +69,7 @@ Imports:
rio,
rlang (>= 0.4.0),
rmarkdown,
rstudioapi,
scales,
sf,
slider,
Expand Down Expand Up @@ -103,7 +105,8 @@ Collate:
'epidict_exports.R'
'epikit_exports.R'
'epitabulate_exports.R'
'AJS_linelist.R'
'AJS_pop.R'
'quartier_shape.R'
'block_shape.R'
'AJS_linelist_internal.R'
'AJS_pop_internal.R'
'shape_quartier_internal.R'
'shape_block_internal.R'
'download_datasets.R'
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export(check_sitrep_templates)
export(constrain_dates)
export(data_frame_from_2x2)
export(dots_to_charlist)
export(download_kobo)
export(download_outbreak_linelist)
export(download_outbreak_pop)
export(download_shape_block)
export(download_shape_quartier)
export(download_survey)
export(fac_from_num)
export(find_breaks)
export(find_date_cause)
Expand Down Expand Up @@ -47,6 +53,7 @@ export(tab_univariate)
export(unite_ci)
export(zcurve)
importFrom(apyramid,age_pyramid)
importFrom(cli,cli_alert_success)
importFrom(dplyr,count)
importFrom(epidict,gen_data)
importFrom(epidict,msf_dict)
Expand Down Expand Up @@ -105,6 +112,7 @@ importFrom(glue,glue)
importFrom(rlang,"!!")
importFrom(rlang,":=")
importFrom(rlang,.data)
importFrom(rstudioapi,selectDirectory)
importFrom(scales,percent_format)
importFrom(stats,setNames)
importFrom(tibble,as_tibble)
8 changes: 4 additions & 4 deletions R/AJS_linelist.R → R/AJS_linelist_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#'
#' @docType data
#'
#' @usage data(AJS_linelist)
#' @usage data(AJS_linelist_internal)
#'
#' @format An object of class \code{"cross"}; see \code{\link[qtl]{read.cross}}.
#'
Expand All @@ -23,6 +23,6 @@
#' @source \href{https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0188240}{Article}
#'
#' @examples
#' data(AJS_linelist)
#' head(AJS_linelist)
"AJS_linelist"
#' data(AJS_linelist_internal)
#' head(AJS_linelist_internal)
"AJS_linelist_internal"
10 changes: 5 additions & 5 deletions R/AJS_pop.R → R/AJS_pop_internal.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Example population data for Hepatatis E virus or Acute Jaundice Syndrome (AJS)
#'
#' Data from a real outbreak of Hepatitis E virus (HEV) infection which
#' Population data from a real outbreak of Hepatitis E virus (HEV) infection which
#' occurred in the Chadian town of Am Timan between October 2016 and
#' April 2017. The Chadian Ministry of Health (MoH) has approved the use
#' of this data for training purposes.
Expand All @@ -11,7 +11,7 @@
#'
#' @docType data
#'
#' @usage data(AJS_pop)
#' @usage data(AJS_pop_internal)
#'
#' @format An object of class \code{"cross"}; see \code{\link[qtl]{read.cross}}.
#'
Expand All @@ -23,6 +23,6 @@
#' @source \href{https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0188240}{Article}
#'
#' @examples
#' data(AJS_pop)
#' head(AJS_pop)
"AJS_pop"
#' data(AJS_pop_internal)
#' head(AJS_pop_internal)
"AJS_pop_internal"
118 changes: 118 additions & 0 deletions R/download_datasets.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#' @title Internal function (not exported - i.e. not userfacing) to reduce code duplication
#'
#' @param path **Run with no arguments to pick a directory interactively**. Path on your computer where the file(s) should be saved to *string*
#' @param dataset The name of the file to save
#'
#' @importFrom rstudioapi selectDirectory
#' @importFrom cli cli_alert_success

generic_download <- function(path = rstudioapi::selectDirectory(), dataset){

## normalise in case given manually
path <- normalizePath(path)

file_to_copy <- system.file(package = "sitrep", "extdata", dataset)

success <- lapply(file_to_copy, file.copy, to = path, overwrite = TRUE)

if(all(as.logical(success))) cli::cli_alert_success("File successfully saved here: {path}")

}


#' @title Access kobo data dictionary
#'
#' @param path **Run with no arguments to pick a directory interactively**. Path on your computer where the file(s) should be saved to *string*
#'
#' @importFrom rstudioapi selectDirectory
#' @importFrom cli cli_alert_success
#'
#' @export
download_kobo <- function(path = rstudioapi::selectDirectory()){

generic_download(path = path, dataset = "mortality_survey_dict.xlsx")

}


#' @title Access AJS outbreak linelist
#'
#' @param path **Run with no arguments to pick a directory interactively**. Path on your computer where the file(s) should be saved to *string*
#'
#' @importFrom rstudioapi selectDirectory
#' @importFrom cli cli_alert_success
#'
#' @export
download_outbreak_linelist <- function(path = rstudioapi::selectDirectory()){

generic_download(path = path, dataset = "AJS_AmTiman.xlsx")

}


#' @title Access AJS outbreak population data
#'
#' @param path **Run with no arguments to pick a directory interactively**. Path on your computer where the file(s) should be saved to *string*
#'
#' @importFrom rstudioapi selectDirectory
#' @importFrom cli cli_alert_success
#'
#' @export
download_outbreak_pop <- function(path = rstudioapi::selectDirectory()){

generic_download(path = path, dataset = "AJS_AmTiman_population.xlsx")

}


#' @title Access Am Timan blocks shapefile
#'
#' @param path **Run with no arguments to pick a directory interactively**. Path on your computer where the file(s) should be saved to *string*
#'
#' @importFrom rstudioapi selectDirectory
#' @importFrom cli cli_alert_success
#'
#' @export
download_shape_block <- function(path = rstudioapi::selectDirectory()){

included_files <- list.files(system.file(package = "sitrep", "extdata"))

dataset <- included_files[grep("Blocksshape", included_files)]

generic_download(path = path, dataset = dataset)

}


#' @title Access Am Timan quartier shapefile
#'
#' @param path **Run with no arguments to pick a directory interactively**. Path on your computer where the file(s) should be saved to *string*
#'
#' @importFrom rstudioapi selectDirectory
#' @importFrom cli cli_alert_success
#'
#' @export
download_shape_quartier <- function(path = rstudioapi::selectDirectory()){

included_files <- list.files(system.file(package = "sitrep", "extdata"))

dataset <- included_files[grep("Quartiersshape", included_files)]

generic_download(path = path, dataset = dataset)

}


#' @title Access fake mortality survey data
#'
#' @param path **Run with no arguments to pick a directory interactively**. Path on your computer where the file(s) should be saved to *string*
#'
#' @importFrom rstudioapi selectDirectory
#' @importFrom cli cli_alert_success
#'
#' @export
download_survey <- function(path = rstudioapi::selectDirectory()){

generic_download(path = path, dataset = "mortality_survey_data.xlsx")

}
8 changes: 4 additions & 4 deletions R/block_shape.R → R/shape_block_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#'
#' @docType data
#'
#' @usage data(block_shape)
#' @usage data(shape_block_internal)
#'
#' @format An object of class \code{"cross"}; see \code{\link[qtl]{read.cross}}.
#'
Expand All @@ -23,6 +23,6 @@
#' @source \href{https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0188240}{Article}
#'
#' @examples
#' data(block_shape)
#' head(block_shape)
"block_shape"
#' data(shape_block_internal)
#' head(shape_block_internal)
"shape_block_internal"
8 changes: 4 additions & 4 deletions R/quartier_shape.R → R/shape_quartier_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#'
#' @docType data
#'
#' @usage data(quartier_shape)
#' @usage data(shape_quartier_internal)
#'
#' @format An object of class \code{"cross"}; see \code{\link[qtl]{read.cross}}.
#'
Expand All @@ -23,6 +23,6 @@
#' @source \href{https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0188240}{Article}
#'
#' @examples
#' data(quartier_shape)
#' head(quartier_shape)
"quartier_shape"
#' data(shape_quartier_internal)
#' head(shape_quartier_internal)
"shape_quartier_internal"
Binary file removed data/AJS_linelist.rda
Binary file not shown.
Binary file added data/AJS_linelist_internal.rda
Binary file not shown.
Binary file removed data/AJS_pop.rda
Binary file not shown.
Binary file added data/AJS_pop_internal.rda
Binary file not shown.
Binary file removed data/block_shape.rda
Binary file not shown.
Binary file removed data/quartier_shape.rda
Binary file not shown.
Binary file added data/shape_block_internal.rda
Binary file not shown.
Binary file added data/shape_quartier_internal.rda
Binary file not shown.
39 changes: 21 additions & 18 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 32f5d4e

Please sign in to comment.