Skip to content

Commit

Permalink
clean up help files following R CMD check
Browse files Browse the repository at this point in the history
mainly cleaning wrong `param` tags, links etc
  • Loading branch information
mjwestgate committed Dec 11, 2024
1 parent f526cb2 commit 023ee8d
Show file tree
Hide file tree
Showing 39 changed files with 164 additions and 116 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
^pkgdown$
^data-raw$
^.github$
^doc$
^Meta$
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ rsconnect/
tests/my_tests.R
docs
inst/doc
/doc/
/Meta/
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Imports:
cli,
dplyr,
glue,
here,
hms,
lubridate,
purrr,
Expand All @@ -31,19 +30,21 @@ Imports:
stringr,
tibble,
tidyr,
nanoparquet,
uuid
Suggests:
gt,
here,
knitr,
nanoparquet,
ozmaps,
readr,
rmarkdown,
testthat (>= 3.0.0)
License: GPL-3 + file LICENSE
URL: https://corella.ala.org.au
Encoding: UTF-8
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Config/testthat/edition: 3
VignetteBuilder: knitr
LazyData: true
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ importFrom(lubridate,ymd_hms)
importFrom(purrr,keep)
importFrom(purrr,map)
importFrom(purrr,pluck)
importFrom(rlang,.data)
importFrom(rlang,abort)
importFrom(rlang,as_label)
importFrom(rlang,caller_env)
Expand Down Expand Up @@ -109,5 +110,6 @@ importFrom(sf,st_geometry_type)
importFrom(sf,st_is)
importFrom(stringr,str_remove_all)
importFrom(tibble,lst)
importFrom(tibble,tibble)
importFrom(tidyr,replace_na)
importFrom(tidyr,unnest)
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# corella 0.1.0

Welcome to {corella}!
11 changes: 5 additions & 6 deletions R/check_occurrences.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ check_dataset <- function(.df){
fields <- colnames(.df)
available_checks <- fn_to_term_table() |>
bind_rows() |>
select(dwc_term) |>
select("dwc_term") |>
pull()
checkable_fields <- fields[fields %in% available_checks]

Expand Down Expand Up @@ -63,12 +63,10 @@ check_dataset <- function(.df){
summary_message(check_results, checkable_fields)
cat_line()


## Darwin Core compliance
# dwc_spinny_message(c("Meets minimum requirements for Darwin Core terms"))
check_min_req_dwc(checkable_fields)


## Error Messages

# truncate
Expand All @@ -81,11 +79,11 @@ check_dataset <- function(.df){

# split messages by function for message formatting
results_split <- check_results |>
unnest(messages) |>
unnest(.data$messages) |>
mutate(
term = factor(term, levels = unique(term)) # maintain original term order
) |>
group_split(term)
group_split(.data$term)

# print preserved errors in a nice format
results_split |>
Expand Down Expand Up @@ -114,9 +112,10 @@ check_dataset <- function(.df){
#' @importFrom cli cli_progress_update
#' @importFrom cli ansi_align
#' @importFrom cli ansi_nchar
#' @importFrom stringr str_remove_all
#' @importFrom rlang cnd_muffle
#' @importFrom rlang exec
#' @importFrom stringr str_remove_all
#' @importFrom tibble tibble
#' @noRd
#' @keywords Internal
check_all <- function(fn, .df, checkable_fields) {
Expand Down
2 changes: 1 addition & 1 deletion R/corella-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#'
#' * [use_events()] basic information on observation events (`eventID`, `parentEventID`, `eventType`)
#' * [use_occurrences()] basic information on observations (`occurrenceID`, `basisOfRecord`)
#' * [use_scientificName()] record the highest level of taxonomic specificity in the dataset (`scientificName`, `scientificNameAuthorship`, `taxonRank`)
#' * [use_scientific_name()] record the highest level of taxonomic specificity in the dataset (`scientificName`, `scientificNameAuthorship`, `taxonRank`)
#' * [use_taxonomy()] to specify higher taxonomic columns (`kingdom`, `phylum`, `class`, `order`, `family`, `genus`, `species`, `specificEpithet`, `vernacularName`)
#' * [use_coordinates()] for spatial data (`decimalLatitude`, `decimalLongitude`, `geodeticDatum`, `coordinateUncertaintyInMeters`, `coordinatePrecision`)
#' * [use_sf()] for spatial data in `sf` format
Expand Down
4 changes: 2 additions & 2 deletions R/darwin_core_terms.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#' \item{comments}{Further information from TDWG.}
#' \item{examples}{Examples of how the field should be populated.}
#' }
#' @seealso [occurrence_fields()] and [event_fields()] to get terms for use in
#' `[dplyr::select()]`
#' @seealso [occurrence_terms()] and [event_terms()] to get terms for use in
#' [dplyr::select()]
#' @source Slightly modified version of a table supplied by TDWG at
#' [this link](https://github.com/tdwg/dwc/blob/master/vocabulary/term_versions.csv).
"darwin_core_terms"
48 changes: 22 additions & 26 deletions R/suggest_workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ check_dataframe <- function(.df,
#'
#' @param .df vector of values
#' @param dwc_terms vector of valid Darwin Core terms against which .df should be compared
#' @importFrom dplyr pull
#' @importFrom dplyr filter
#' @importFrom dplyr distinct
#' @importFrom rlang is_empty
#' @importFrom cli cli_div
#' @importFrom cli cli_h1
#' @importFrom cli cli_h2
#' @importFrom cli cli_h3
#' @importFrom cli cli_end
#' @importFrom dplyr pull
#' @importFrom dplyr filter
#' @importFrom dplyr distinct
#' @importFrom rlang is_empty
#' @noRd
#' @keywords Internal
check_contains_terms <- function(.df,
Expand Down Expand Up @@ -106,23 +106,21 @@ check_contains_terms <- function(.df,
# retrieve required term match results
req_terms_results <- check_required_terms(user_column_names)


## Suggested workflow & Additional functions

# Function matching for suggested workflow
main_functions <- fn_to_term_table()$main
other_functions <- fn_to_term_table()$optional

suggested_functions <- main_functions |>
filter(!dwc_term %in% matched_values) |>
distinct(use_function) |>
pull(use_function)
filter(!.data$dwc_term %in% matched_values) |>
distinct(.data$use_function) |>
pull("use_function")

optional_functions <- other_functions |>
filter(dwc_term %in% matched_values) |>
distinct(use_function) |>
pull(use_function)

filter(.data$dwc_term %in% matched_values) |>
distinct(.data$use_function) |>
pull("use_function")

# this wraps text (which might not be optimal for this table)
# withr::with_options(
Expand Down Expand Up @@ -385,43 +383,41 @@ fn_to_term_table <- function() {
}




#' Build table for messaging about minimum required terms
#'
#' @importFrom tidyr unnest
#' @importFrom dplyr case_when
#' @importFrom dplyr group_by
#' @importFrom dplyr select
#' @importFrom dplyr full_join
#' @importFrom dplyr join_by
#' @importFrom tidyr replace_na
#' @importFrom tidyr unnest
#' @importFrom cli ansi_align
#' @importFrom cli ansi_collapse
#' @importFrom cli ansi_nchar
#' @importFrom cli col_blue
#' @importFrom cli col_green
#' @importFrom cli col_red
#' @importFrom cli symbol
#' @importFrom dplyr case_when
#' @importFrom dplyr group_by
#' @importFrom dplyr select
#' @importFrom dplyr full_join
#' @importFrom dplyr join_by
#' @importFrom rlang .data
#' @importFrom tidyr replace_na
#' @importFrom tidyr unnest
#' @noRd
#' @keywords Internal
build_req_terms_table <- function(req_terms) {

# Unnest & concatenate terms by group
missing_results <- req_terms |>
select(-matched) |>
select(-"matched") |>
unnest(cols = c(missing)) |>
group_by(term_group) |>
group_by(.data$term_group) |>
mutate( # glue names
missing = ansi_collapse(missing, sep = ", ", last = ", ")
) |>
unique()

matched_results <- req_terms |>
select(-missing) |>
select(-"missing") |>
unnest(cols = c(matched)) |>
group_by(term_group) |>
group_by(.data$term_group) |>
mutate( # glue names
matched = ansi_collapse(matched, sep = ", ", last = ", ")
) |>
Expand Down
7 changes: 6 additions & 1 deletion R/use_abundance.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
#' @param individualCount The number of individuals present
#' @param organismQuantity A number or enumeration value for the quantity of
#' organisms. Used together with `organismQuantityType` to provide context.
#' @param organismQuantityType The type of quantification system used for `organismQuantity`
#' @param organismQuantityType The type of quantification system used for
#' `organismQuantity`.
#' @param .keep Control which columns from .data are retained in the output.
#' Note that unlike [dplyr::mutate()], which defaults to `"all"` this defaults to
#' `"unused"`; i.e. only keeps Darwin Core fields, and not those fields used to
#' generate them.
#' @returns A tibble with the requested fields (see details).
#'
#' @details
Expand Down
4 changes: 2 additions & 2 deletions R/use_collection.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
#' informative errors, and serves as a useful lookup for fields in
#' the Darwin Core Standard.
#'
#' @param df a `data.frame` or `tibble` that the column should be appended to.
#' @param .df a `data.frame` or `tibble` that the column should be appended to.
#' @param datasetID An identifier for the set of data. May be a global unique
#' identifier or an identifier specific to a collection or institution.
#' @param datasetName The name identifying the data set from which the record
#' was derived.
#' @param catalogNumber A unique identifier for the record within the data set
#' or collection.
#' @param .keep Control which columns from .data are retained in the output.
#' Note that unlike `dplyr::mutate`, which defaults to `"all"` this defaults to
#' Note that unlike [dplyr::mutate()], which defaults to `"all"` this defaults to
#' `"unused"`; i.e. only keeps Darwin Core fields, and not those fields used to
#' generate them.
#' @returns A tibble with the requested fields added.
Expand Down
7 changes: 3 additions & 4 deletions R/use_coordinates.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
#'
#' This function helps format standard location fields to a `tibble`.
#'
#' In
#' practice this is no different from using `mutate()`, but gives some
#' In practice this is no different from using `mutate()`, but gives some
#' informative errors, and serves as a useful lookup for how spatial fields are
#' represented in the Darwin Core Standard.
#' @param df a `data.frame` or `tibble` that the column should be appended to.
#' @param .df a `data.frame` or `tibble` that the column should be appended to.
#' @param decimalLatitude The latitude in decimal degrees
#' @param decimalLongitude The longitude in decimal degrees
#' @param geodeticDatum The datum or spatial reference system that coordinates
Expand All @@ -21,7 +20,7 @@
#' `decimalLongitude` are supplied to. `coordinatePrecision` should be no less
#' than 0.00001 if data were collected using GPS.
#' @param .keep Control which columns from .data are retained in the output.
#' Note that unlike `dplyr::mutate`, which defaults to `"all"` this defaults to
#' Note that unlike [dplyr::mutate()], which defaults to `"all"` this defaults to
#' `"unused"`; i.e. only keeps Darwin Core fields, and not those fields used to
#' generate them.
#' @returns A tibble with the requested fields added.
Expand Down
7 changes: 3 additions & 4 deletions R/use_datetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
#'
#' This function helps format standard date/time fields to a `tibble`.
#'
#' In
#' practice this is no different from using `mutate()`, but gives some
#' In practice this is no different from using `mutate()`, but gives some
#' informative errors, and serves as a useful lookup for how spatial fields are
#' represented in the Darwin Core Standard.
#' @param .df a `data.frame` or `tibble` that the column should be appended to.
#' @param eventDate The date or date + time that the observation/event occurred.
#' @param year The year of the observation/event.
#' @param month The month of the observation/event.
#' @param day The day of the observation/event.
#' @param time The time of the observation/event.
#' @param eventTime The time of the observation/event.
#' @param .keep Control which columns from .data are retained in the output.
#' Note that unlike `dplyr::mutate`, which defaults to `"all"` this defaults to
#' Note that unlike [dplyr::mutate()], which defaults to `"all"` this defaults to
#' `"unused"`; i.e. only keeps Darwin Core fields, and not those fields used to
#' generate them.
#' @param .messages (logical) Should informative messages be shown? Defaults to
Expand Down
4 changes: 2 additions & 2 deletions R/use_individual_traits.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' informative errors, and serves as a useful lookup for fields in
#' the Darwin Core Standard.
#'
#' @param df a `data.frame` or `tibble` that the column should be appended to.
#' @param .df a `data.frame` or `tibble` that the column should be appended to.
#' @param individualID An identifier for an individual or named group of
#' individual organisms represented in the Occurrence. Meant to accommodate
#' resampling of the same individual or group for monitoring purposes. May
Expand All @@ -23,7 +23,7 @@
#' @param reproductiveCondition The reproductive condition of the biological
#' individual.
#' @param .keep Control which columns from .data are retained in the output.
#' Note that unlike `dplyr::mutate`, which defaults to `"all"` this defaults to
#' Note that unlike [dplyr::mutate()], which defaults to `"all"` this defaults to
#' `"unused"`; i.e. only keeps Darwin Core fields, and not those fields used to
#' generate them.
#' @returns A tibble with the requested fields added.
Expand Down
4 changes: 2 additions & 2 deletions R/use_locality.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#'
#' Locality information refers to a description of a place, rather than a
#' spatial coordinate.
#' @param df a `data.frame` or `tibble` that the column should be appended to.
#' @param .df a `data.frame` or `tibble` that the column should be appended to.
#' @param continent (string) Valid continent. See details.
#' @param country Valid country name. See `country_codes`.
#' @param countryCode Valid country code. See `country_codes`.
#' @param stateProvince A sub-national region.
#' @param locality A specific location, such as a property or address.
#' @param .keep Control which columns from .data are retained in the output.
#' Note that unlike `dplyr::mutate`, which defaults to `"all"` this defaults to
#' Note that unlike [dplyr::mutate()], which defaults to `"all"` this defaults to
#' `"unused"`; i.e. only keeps Darwin Core fields, and not those fields used to
#' generate them.
#' @returns A tibble with the requested fields.
Expand Down
7 changes: 5 additions & 2 deletions R/use_measurements.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
#' This function is a work in progress, and should be used with caution.
#'
#' @param .df a `data.frame` or `tibble` that the column should be appended to.
#' @param cols vector of column names to be included as 'measurements'. Unquoted.
#' @param unit vector of strings giving units for each variable
#' @param type vector of strings giving a description for each variable
#' @param .keep Control which columns from .data are retained in the output.
#' Note that unlike `dplyr::mutate`, which defaults to `"all"` this defaults to
#' Note that unlike [dplyr::mutate()], which defaults to `"all"` this defaults to
#' `"unused"`; i.e. only keeps Darwin Core fields, and not those fields used to
#' generate them.
#' @returns A tibble with the requested fields added.
Expand All @@ -19,8 +22,8 @@
use_measurements <- function(
.df,
cols = NULL,
type = NULL,
unit = NULL,
type = NULL,
.keep = "unused"
){
if(missing(.df)){
Expand Down
4 changes: 2 additions & 2 deletions R/use_observer.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
#' In practice this is no different from using `mutate()`, but gives some
#' informative errors, and serves as a useful lookup for fields in
#' the Darwin Core Standard.
#' @param df a `data.frame` or `tibble` that the column should be appended to.
#' @param .df a `data.frame` or `tibble` that the column should be appended to.
#' @param recordedBy Names of people, groups, or organizations responsible for
#' recording the original occurrence. The primary collector or observer should
#' be listed first.
#' @param recordedByID The globally unique identifier for the person, people,
#' groups, or organizations responsible for recording the original occurrence.
#' @param .keep Control which columns from .data are retained in the output.
#' Note that unlike `dplyr::mutate`, which defaults to `"all"` this defaults to
#' Note that unlike [dplyr::mutate()], which defaults to `"all"` this defaults to
#' `"unused"`; i.e. only keeps Darwin Core fields, and not those fields used to
#' generate them.
#' @returns A tibble with the requested fields added.
Expand Down
Loading

0 comments on commit 023ee8d

Please sign in to comment.