-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45244fb
commit 93bd920
Showing
22 changed files
with
232 additions
and
171 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
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,64 +1,108 @@ | ||
|
||
|
||
#' Generate all SIS connect csv files | ||
#' | ||
#' @param keys (data frame) Derived from [`get_name_keys()`] function. Must include at least GBIF_usageKey to obtain GBIF occurrences | ||
#' @param unique_id (character) Unique identifier - default is the GBIF usage key | ||
#' @param first_name (character) First name of assessor | ||
#' @param second_name (character) Second name of assessor | ||
#' @param email (character) Email of assessor | ||
#' @param institution (character) Name of institution or affiliation | ||
#' @param gbif_ref (data frame) A GBIF download citation according to IUCN format. | ||
#' @param powo_ref (data frame) A citation for use of POWO according to IUCN format. | ||
#' @param native_ranges (data frame) Native ranges derived from [`get_native_range()`] | ||
#' @param family (character) Field containing the family | ||
#' @param genus (character) Field containing the genus | ||
#' @param species (character) Field containing the specific epithet | ||
#' @param taxonomicAuthority (character) Field containing the taxonomic authority | ||
#' @param kingdom (character) Default is 'plantae', but can also be 'fungi' | ||
#' | ||
#' @return Returns an SIS compliant zip file | ||
#' @export | ||
|
||
make_sis_csvs <- | ||
function(unique_id, wcvp_ipni_id, first_name, second_name, email, | ||
institution, gbif_ref = NULL, native_ranges, | ||
family, genus, species, taxonomicAuthority, | ||
kingdom = "plantae", powo_ref = FALSE) { | ||
|
||
function(unique_id, | ||
wcvp_ipni_id, | ||
first_name, | ||
second_name, | ||
email, | ||
institution, | ||
gbif_ref = NULL, | ||
powo_ref = FALSE, | ||
native_ranges = NULL, | ||
family, | ||
genus, | ||
species, | ||
taxonomicAuthority, | ||
kingdom = "plantae") | ||
{ | ||
if (kingdom == "plantae") { | ||
|
||
# get most of the csvs here | ||
countries <- sis_countries(unique_id, wcvp_ipni_id, native_ranges) | ||
if (!is.null(native_ranges)) { | ||
countries <- sis_countries(native_ranges) | ||
} | ||
allfields <- sis_allfields(unique_id) | ||
assessments <- sis_assessments(unique_id) | ||
plantspecific <- sis_plantspecific(unique_id, kingdom) | ||
habitats <- sis_habitats(unique_id) | ||
credits <- sis_credits(unique_id, first_name, second_name, email, affiliation = institution) | ||
taxonomy <- sis_taxonomy(unique_id, family, genus, species, taxonomicAuthority) | ||
|
||
# need to embed map into the function, but these are a bit awkward - try again later | ||
references <- purrr::map_dfr(unique_id, sis_references, powo_ref = powo_ref, gbif_ref) | ||
# need to embed map into the function, but refs a bit awkward - try again later | ||
references <- purrr::map_dfr(unique_id, sis_references, powo_ref = powo_ref, gbif_ref = gbif_ref) | ||
|
||
return( | ||
list(allfields = allfields, assessments = assessments, plantspecific = plantspecific, | ||
habitats = habitats, taxonomy = taxonomy, credits = credits, references = references, | ||
countries = countries | ||
# list of default results - these should always be generated | ||
results <- | ||
list( | ||
allfields = allfields, | ||
assessments = assessments, | ||
plantspecific = plantspecific, | ||
habitats = habitats, | ||
credits = credits, | ||
taxonomy = taxonomy, | ||
references = references | ||
) | ||
) | ||
|
||
# countries df depends on native ranges, so only add countries if exists | ||
if (exists("countries")) { | ||
results$countries <- countries | ||
} | ||
|
||
return(results) | ||
} | ||
|
||
if (kingdom == "fungi") { | ||
|
||
# get most of the csvs here | ||
#countries <- sis_countries(unique_id, wcvp_ipni_id, native_ranges) | ||
if (!is.null(native_ranges)) { | ||
countries <- sis_countries(native_ranges) | ||
} | ||
allfields <- sis_allfields(unique_id) | ||
assessments <- sis_assessments(unique_id) | ||
plantspecific <- sis_plantspecific(unique_id, kingdom) | ||
habitats <- sis_habitats(unique_id) | ||
credits <- sis_credits(unique_id, first_name, second_name, email, affiliation = institution) | ||
taxonomy <- sis_taxonomy(unique_id, family,genus, species, taxonomicAuthority) | ||
taxonomy <- sis_taxonomy(unique_id, family, genus, species, taxonomicAuthority) | ||
|
||
# need to embed map into the function, but these are a bit awkward - try again later | ||
# need to embed map into the function, but refs a bit awkward - try again later | ||
references <- purrr::map_dfr(unique_id, sis_references, gbif_ref, powo_ref) | ||
|
||
return( | ||
list(allfields = allfields, assessments = assessments, plantspecific = plantspecific, | ||
habitats = habitats, credits = credits, taxonomy = taxonomy, references = references | ||
# list of default results - these should always be generated | ||
results <- | ||
list( | ||
allfields = allfields, | ||
assessments = assessments, | ||
plantspecific = plantspecific, | ||
habitats = habitats, | ||
credits = credits, | ||
taxonomy = taxonomy, | ||
references = references | ||
) | ||
) | ||
} | ||
|
||
# countries df depends on native ranges, so only add countries if exists | ||
if (exists("countries")) { | ||
results$countries <- countries | ||
} | ||
|
||
return(results) | ||
|
||
} | ||
} |
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.