Skip to content

Commit

Permalink
doc: document code and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ahasverus committed Nov 20, 2024
1 parent 4e2934a commit 9db6919
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
26 changes: 26 additions & 0 deletions R/dl_pantheria_data.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
#' Download PanTHERIA dataset
#'
#' @description
#' This function downloads the PanTHERIA dataset (Kate _et al._ 2009) hosted on
#' the GitHub repository <https://github.com/rdatatoolbox/datarepo/>. The file
#' won't be downloaded if already exists locally (except if `overwrite = TRUE`).
#'
#' The file `PanTHERIA_1-0_WR05_Aug2008.txt` will be stored in
#' `data/pantheria/`. This folder will be created if required.
#'
#' @param overwrite a logical. If `TRUE`, the file will be downloaded again and
#' the previous version will be erased. Default is `FALSE`.
#'
#' @return No return value.
#'
#' @export
#'
#' @references
#' Kate EJ, Bielby J, Cardillo M _et al._ (2009) PanTHERIA: A species-level
#' database of life history, ecology, and geography of extant and recently
#' extinct mammals. _Ecology_, 90, 2648.
#' DOI: <https://doi.org/10.1890/08-1494.1>.
#'
#' @examples
#' dl_pantheria_data()

dl_pantheria_data <- function(overwrite = FALSE) {

# Define destination directory ----
Expand Down
30 changes: 30 additions & 0 deletions R/dl_wildfinder_data.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
#' Download WWF WildFinder dataset
#'
#' @description
#' This function downloads the WWF WildFinder dataset (World Wildlife Fund 2006)
#' hosted on the GitHub repository <https://github.com/rdatatoolbox/datarepo/>.
#' The files won't be downloaded if already exist locally (except if
#' `overwrite = TRUE`).
#'
#' Three `.csv` files will be saved in `data/wildfinder/`:
#' - `wildfinder-ecoregions_list.csv`
#' - `wildfinder-ecoregions_species.csv`
#' - `wildfinder-mammals_list.csv`
#'
#' The folder `data/wildfinder/` will be created if required.
#'
#' @param overwrite a `logical`. If `TRUE`, the files will be downloaded again
#' and the previous versions will be erased. Default is `FALSE`.
#'
#' @return No return value.
#'
#' @export
#'
#' @references
#' World Wildlife Fund (2006) WildFinder: Online database of species
#' distributions. Version Jan-06.
#' URL: <https://www.worldwildlife.org/pages/wildfinder-database>.
#'
#' @examples
#' dl_wildfinder_data()

dl_wildfinder_data <- function(overwrite = FALSE) {

# Define destination directory ----
Expand Down
13 changes: 13 additions & 0 deletions analyses/download-data.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Download project raw data
#
# This script will download the PanTHERIA and WWF WildFinder datasets. The
# four files will be stored in `data/`.
#
# All functions used in the script have been developed for this project
# and can be found in the folder R/.
#
# Author: Jane Doe
# Email: jane.doe@mail.me
# Date: 2024/12/02


## Download PanTHERIA database ----

dl_pantheria_data()
Expand Down

0 comments on commit 9db6919

Please sign in to comment.