-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from AtlasOfLivingAustralia/dev
release version 2.1.1
- Loading branch information
Showing
72 changed files
with
1,368 additions
and
635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/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: | ||
|
||
name: R-CMD-check.yaml | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::rcmdcheck | ||
needs: check | ||
|
||
- uses: r-lib/actions/check-r-package@v2 | ||
with: | ||
upload-snapshots: true | ||
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,109 @@ | ||
#' Generate a citation for occurrence data | ||
#' | ||
#' If a `data.frame` was generated using [atlas_occurrences()], | ||
#' and the `mint_doi` argument was set to `TRUE`, the DOI associated | ||
#' with that dataset is appended to the resulting `data.frame` as an | ||
#' attribute. This function simply formats that DOI as a citation that can be | ||
#' included in a scientific publication. Please also consider citing this | ||
#' package, using the information in `citation("galah")`. | ||
#' @param data data.frame: occurrence data generated by | ||
#' [atlas_occurrences()] | ||
#' @return A string containing the citation for that dataset. | ||
#' If a `tibble` containing occurrences was generated using galah (either via | ||
#' \code{\link[=collect.data_request]{collect()}} or [atlas_occurrences()]), it | ||
#' will usually contain associated metadata stored in `attributes()` that can be | ||
#' used to build a citation for that dataset. This function simply extracts that | ||
#' information, formats it, then both invisibly returns the formatted citation | ||
#' and prints it to the console. | ||
#' @param data A `tibble` generated by [atlas_occurrences()] or similar | ||
#' @return Invisibly returns a string containing the citation for that dataset. | ||
#' Primarily called for the side-effect of printing this string to the console. | ||
#' @examples \dontrun{ | ||
#' atlas_citation(doi) | ||
#' x <- galah_call() |> | ||
#' identify("Heleioporus") |> | ||
#' filter(year == 2022) |> | ||
#' collect() | ||
#' atlas_citation(x) | ||
#' } | ||
#' @export | ||
|
||
atlas_citation <- function(data) { | ||
doi <- attributes(data)$doi | ||
if (is.null(doi)) { | ||
bullets <- c( | ||
"This data does not have a DOI attached.", | ||
i = "Did you set `atlas_occurrences(mint_doi = TRUE)`?", | ||
i = "`atlas_citation` extracts this citation info when present." | ||
) | ||
warn(bullets, call = caller_env()) | ||
glue("Please consider citing R & galah. To do so, call: | ||
citation() | ||
citation('galah')") | ||
}else{ | ||
current_date <- format(Sys.Date(), "%e %B %Y") |> | ||
# get basic information from file | ||
modified_date <- attributes(data)$modified_date | ||
if(is.null(modified_date)){ | ||
modified_date <- Sys.Date() |> | ||
format("%e %B %Y") |> | ||
trimws() | ||
} | ||
doi <- attributes(data)$doi | ||
citation <- attributes(data)$citation | ||
# search_url <- attributes(data)$search_url | ||
|
||
# get existing citation info | ||
r_citation <- citation() |> | ||
print(style = 'text') |> | ||
utils::capture.output() |> | ||
glue_collapse(sep = " ") | ||
galah_citation <- c("Westgate M, Kellie D, Stevenson M & Newman P (2025):", | ||
"_galah: Biodiversity Data from the GBIF Node Network_.", | ||
"R package version 2.1.1.", | ||
"doi: 10.32614/CRAN.package.galah") |> | ||
glue_collapse(sep = " ") | ||
|
||
# ask users to cite galah and R | ||
suffix_text <- glue(" | ||
Please consider citing R & galah, in addition to your dataset: | ||
{r_citation} | ||
{galah_citation}") | ||
|
||
|
||
# set case when DOI is missing | ||
if(!is.null(doi)) { | ||
# ALA | ||
if(grepl("10.26197/ala.", doi)){ | ||
org_text <- "Atlas of Living Australia" | ||
description <- "Occurrence download" | ||
result <- glue(" | ||
The citation for this dataset is: | ||
Atlas of Living Australia ({modified_date}) Occurrence download {doi} | ||
{suffix_text} | ||
") | ||
cli::cli_text(result) | ||
invisible(result) | ||
# GBIF | ||
}else if(grepl("10.15468/dl.", doi)){ | ||
result <- glue(" | ||
The citation for this dataset is: | ||
GBIF.org ({modified_date}) GBIF Occurrence Download {doi} | ||
{suffix_text} | ||
") | ||
cli::cli_text(result) | ||
invisible(result) | ||
# Unknown | ||
}else{ | ||
org_text <- "GBIF.org" | ||
description <- "GBIF Occurrence Download" | ||
bullets <- c( | ||
"The supplied DOI was not recognized.", | ||
i = "Please consider checking the atlas in question for their citation guidelines" | ||
) | ||
cli::cli_warn(bullets) | ||
invisible(bullets) | ||
} | ||
}else{ | ||
if(!is.null(citation)){ | ||
result <- glue(" | ||
The citation for this dataset is: | ||
{citation} | ||
{suffix_text} | ||
") | ||
cli::cli_text(result) | ||
invisible(result) | ||
}else{ | ||
bullets <- c( | ||
"This dataset does not have any citation information attached.", | ||
i = "Please consider checking the atlas in question for their citation guidelines" | ||
) | ||
cli::cli_warn(bullets) | ||
invisible(bullets) | ||
} | ||
glue(" | ||
{org_text} ({current_date}) {description} {doi} | ||
Please consider citing R & galah, in addition to your dataset. To do so, call: | ||
citation() | ||
citation('galah') | ||
") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.