Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #250

Merged
merged 27 commits into from
Nov 19, 2024
Merged

Dev #250

Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ca1cf46
switch ALA biocache APIs to api.ala.org.au
mjwestgate Apr 24, 2024
94a4b56
Update R version dependency #240
daxkellie May 29, 2024
d744371
Improve regex in `check_fields()` #237
daxkellie Jun 3, 2024
94721f2
Add Lists test system to test workflow
daxkellie Jul 1, 2024
7d2fa0f
Handle `search_taxa()` results with multiple issues #244
daxkellie Jul 25, 2024
163c89f
Append `recordID` to query #239
daxkellie Aug 29, 2024
82959c4
Add `cli_warn()` to NAMESPACE
daxkellie Aug 29, 2024
cd55f74
Revert to previous behaviour #239
daxkellie Aug 29, 2024
c35eb22
Simplify help files, increase consistency with dplyr
mjwestgate Oct 25, 2024
69f8049
Fix colours on galah pkgdown site
daxkellie Oct 30, 2024
8ad340d
Add `?taxonomic_searches` help docs #241
daxkellie Oct 31, 2024
067a41c
Update help files
mjwestgate Nov 5, 2024
ab87293
Updates to vignettes & associated bug fixes
mjwestgate Nov 5, 2024
ff668bb
Misc tidy fixes
mjwestgate Nov 6, 2024
65b94b1
Fix pkgdown site navbar styling
daxkellie Nov 6, 2024
43f4b55
Fix pkgdown dropdown hover colour
daxkellie Nov 6, 2024
3d34208
Ensure that `check_fields()` works consistently without using regex
mjwestgate Nov 8, 2024
7eadd83
Check behaviour of living atlases shown by `test`
mjwestgate Nov 11, 2024
a4ba30f
Expand support for `atlas_media()`
mjwestgate Nov 13, 2024
26722c6
misc bug fixes from test()
mjwestgate Nov 14, 2024
34ef811
Finish updating other atlases
mjwestgate Nov 18, 2024
20e3c38
Update NEWS.md
mjwestgate Nov 18, 2024
d027652
Bug fix for atlas_media()
mjwestgate Nov 18, 2024
226cf16
add skip_if_offline() to collapse() query
mjwestgate Nov 18, 2024
9182bba
remove bad links, update vignettes
mjwestgate Nov 18, 2024
70a4638
minor bug fixes
mjwestgate Nov 19, 2024
8cb2b9e
fix links in spatial filtering
mjwestgate Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Misc tidy fixes
- update to version 2.0.3
- ensure all examples sections contain \dontrun{ to avoid CRAN errors
- remove galah_down_to errors
- fix errors in vignettes resulting from non-installed packages
- fix issues identified by R CMD check
  • Loading branch information
mjwestgate committed Nov 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit ff668bb048b941deb306e23f9c89208eb08c0a84
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: galah
Type: Package
Title: Biodiversity Data from the GBIF Node Network
Version: 2.0.2
Version: 2.0.3
Authors@R:
c(person(given = "Martin",
family = "Westgate",
@@ -26,7 +26,7 @@ Description: The Global Biodiversity Information Facility
Australia ('ALA', <https://www.ala.org.au>). 'galah' enables the R community
to directly access data and resources hosted by 'GBIF' and its partner nodes.
Depends:
R (>= 4.2.2)
R (>= 4.3.0)
Imports:
cli,
crayon,
3 changes: 2 additions & 1 deletion R/atlas_distributions.R
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
#' @return An object of classes `sf`, `tbl`, `tbl_df` and `data.frame`
#' (aka a Simple feature collection) of distribution maps, with one column per
#' map, and spatial data stored in the `geometry` column.
#' @examples
#' @examples \dontrun{
#'
#' x <- show_all(distributions) |>
#' slice_head(n = 4)
@@ -21,6 +21,7 @@
#' ggplot() +
#' geom_sf(data = ozmap_country) +
#' geom_sf(data = st_as_sf(x))
#' }
#' @noRd
#' @keywords Internal
atlas_distributions <- function(request = NULL,
18 changes: 12 additions & 6 deletions R/atlas_taxonomy.R
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
#' @order 5
#' @param constrain_ids `string`: Optional string to limit which `taxon_concept_id`'s
#' are returned. This is useful for restricting taxonomy to particular
#' authoritative sources. Default is `"biodiversity.org.au"` for Australia
#' (this can be overridded by setting `constrain_ids = NULL`) and NULL otherwise.
#' Powered by `grepl()` meaning it supports regular expressions.
#' authoritative sources. Default is `"biodiversity.org.au"` for Australia,
#' which is the infix common to National Species List IDs; use
#' `NULL` to suppress source filtering. Regular expressions are supported.
#' @importFrom dplyr bind_rows
#' @importFrom dplyr filter
#' @importFrom dplyr mutate
@@ -38,7 +38,10 @@ atlas_taxonomy <- function(request = NULL,
start_row <- taxa_info |>
mutate(name = str_to_title(taxa_info$scientific_name),
parent_taxon_concept_id = NA) |>
select("name", "rank", "taxon_concept_id", "parent_taxon_concept_id")
select("name",
"rank",
"taxon_concept_id",
"parent_taxon_concept_id")

# build then flatten a tree
taxonomy_tree <- drill_down_taxonomy(start_row,
@@ -49,12 +52,15 @@ atlas_taxonomy <- function(request = NULL,
}
result <- bind_rows(taxonomy_tree)

# remove rows with ranks that are to low
# remove rows with ranks that are too low
index <- rank_index(result$rank)
down_to_index <- rank_index(.query$filter$value)
result |>
filter({{index}} <= {{down_to_index}} | is.na({{index}})) |>
select("name", "rank", "parent_taxon_concept_id", "taxon_concept_id")
select("name",
"rank",
"parent_taxon_concept_id",
"taxon_concept_id")
}

#' Internal function to check whether constraints have been passed
6 changes: 3 additions & 3 deletions R/galah-package.R
Original file line number Diff line number Diff line change
@@ -45,9 +45,9 @@
#'
#' **Execute a query via API**
#'
#' * \code{\link[=collapse_galah]{collapse()}} Convert a `data_request` into a `query`
#' * \code{\link[=compute_galah]{compute()}} Compute a query
#' * \code{\link[=collect_galah]{collect()}}/\code{\link[=atlas_]{atlas_()}}/[collect_media()] Retrieve a database query
#' * \code{\link[=collapse.data_request]{collapse()}} Convert a `data_request` into a `query`
#' * \code{\link[=compute.data_request]{compute()}} Compute a query
#' * \code{\link[=collect.data_request]{collect()}}/\code{\link[=atlas_]{atlas_()}}/[collect_media()] Retrieve a database query
#'
#' **Miscellaneous functions**
#'
7 changes: 3 additions & 4 deletions R/galah_call.R
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
#' Accepted values of the `type` argument are set by the underlying `request_`
#' functions. While all accepted types can be set directly, some are affected
#' by later functions. The most common example is that adding
#' \code{\link[=count.data_request()]{count()}} to a pipe updates `type`,
#' \code{\link[=count.data_request]{count()}} to a pipe updates `type`,
#' converting `type = "occurrences"` to `type = "occurrences-count"` (and ditto
#' for `type = "species"`).
#'
@@ -120,8 +120,7 @@ request_data <- function(type = c("occurrences",
"occurrences-doi",
# "distributions",
"species",
"species-count",
"taxonomy"
"species-count"
),
...){
if(!missing(type)){
@@ -181,7 +180,7 @@ request_metadata <- function(type = c("fields",
i = "See `?show_all()` for a list of valid metadata types.",
x = glue("Can't find metadata type `{type}`.")
)
abort(bullets, call = error_call)
abort(bullets)
}
x <- list(type = type)
class(x) <- "metadata_request"
20 changes: 10 additions & 10 deletions R/galah_select.R
Original file line number Diff line number Diff line change
@@ -9,30 +9,30 @@
#'
#' `select()` supports `dplyr` **selection helpers**, including:
#'
#' * \code{\link[dplyr]{everything()}}: Matches all variables.
#' * \code{\link[dplyr]{last_col()}}: Select last variable, possibly with an
#' * \code{\link[dplyr]{everything}}: Matches all variables.
#' * \code{\link[dplyr]{last_col}}: Select last variable, possibly with an
#' offset.
#'
#' Other helpers select variables by matching patterns in their names:
#'
#' * \code{\link[dplyr]{starts_with()}}: Starts with a prefix.
#' * \code{\link[dplyr]{ends_with()}}: Ends with a suffix.
#' * \code{\link[dplyr]{contains()}}: Contains a literal string.
#' * \code{\link[dplyr]{matches()}}: Matches a regular expression.
#' * \code{\link[dplyr]{num_range()}}: Matches a numerical range like x01,
#' * \code{\link[dplyr]{starts_with}}: Starts with a prefix.
#' * \code{\link[dplyr]{ends_with}}: Ends with a suffix.
#' * \code{\link[dplyr]{contains}}: Contains a literal string.
#' * \code{\link[dplyr]{matches}}: Matches a regular expression.
#' * \code{\link[dplyr]{num_range}}: Matches a numerical range like x01,
#' x02, x03.
#'
#' Or from variables stored in a character vector:
#'
#' * \code{\link[dplyr]{all_of()}}: Matches variable names in a character
#' * \code{\link[dplyr]{all_of}}: Matches variable names in a character
#' vector. All names must be present, otherwise an out-of-bounds error is
#' thrown.
#' * \code{\link[dplyr]{any_of()}}: Same as `all_of()`, except that no error
#' * \code{\link[dplyr]{any_of}}: Same as `all_of()`, except that no error
#' is thrown for names that don't exist.
#'
#' Or using a predicate function:
#'
#' * \code{\link[dplyr]{where()}}: Applies a function to all variables and selects those for which the function returns `TRUE`.
#' * \code{\link[dplyr]{where}}: Applies a function to all variables and selects those for which the function returns `TRUE`.
#' @name select.data_request
#' @param .data An object of class `data_request`, created using [galah_call()].
#' @param ... Zero or more individual column names to include.
3 changes: 2 additions & 1 deletion R/print.R
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
#' @param ... Arguments to be passed to or from other methods
#' @returns Print does not return an object; instead it prints a description
#' of the object to the console
#' @examples
#' @examples \dontrun{
#' # The most common way to start a pipe is with `galah_call()`
#' # later functions update the `data_request` object
#' galah_call() |> # same as calling `request_data()`
@@ -35,6 +35,7 @@
#'
#' # Each `query_set` contains one or more `query` objects
#' x[[3]]
#' }
#' @export
print.data_request <- function(x, # NOTE: use of `x` arg here is for consistency with `print()`,
...
3 changes: 2 additions & 1 deletion R/taxonomic-searches.R
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@
#' \code{\link[=select.data_request]{select()}},
#' \code{\link[=identify.data_request]{identify()}} and [geolocate()] for ways
#' to restrict the information returned by [atlas_()] functions.
#' @examples
#' @examples \dontrun{
#' # Search using a single string.
#' # Note that `search_taxa()` is not case sensitive
#' search_taxa("Reptilia")
@@ -80,4 +80,5 @@
#'
#' # Look up a unique taxon identifier
#' search_identifiers(query = "https://id.biodiversity.org.au/node/apni/2914510")
#' }
NULL
6 changes: 3 additions & 3 deletions man/atlas_.Rd

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

6 changes: 3 additions & 3 deletions man/galah.Rd

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

4 changes: 2 additions & 2 deletions man/galah_call.Rd

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

2 changes: 2 additions & 0 deletions man/print_galah_objects.Rd

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

20 changes: 10 additions & 10 deletions man/select.data_request.Rd

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

2 changes: 2 additions & 0 deletions man/taxonomic_searches.Rd

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

24 changes: 0 additions & 24 deletions tests/testthat/test-galah_down_to.R

This file was deleted.

10 changes: 5 additions & 5 deletions tests/testthat/test-international-GBIF.R
Original file line number Diff line number Diff line change
@@ -323,11 +323,11 @@ test_that("atlas_species works for GBIF", {
expect_gt(nrow(z), 0)
expect_gt(ncol(z), 0)
expect_true(inherits(z, c("tbl_df", "tbl", "data.frame")))
species <- galah_call() |>
galah_filter(year == 2010) |>
galah_identify("Litoria") |>
atlas_species()
expect_equal(z, species)
# species <- galah_call() |>
# galah_filter(year == 2010) |>
# galah_identify("Litoria") |>
# atlas_species()
# expect_equal(z, species)
})

test_that("atlas_media fails for GBIF", {
Loading