-
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.
- Loading branch information
Showing
46 changed files
with
548 additions
and
207 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 |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
^codecov\.yml$ | ||
^doc$ | ||
^Meta$ | ||
^cran-comments\.md$ |
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,28 +1,35 @@ | ||
Package: mammalcol | ||
Title: Access to the List of Mammals Species of Colombia | ||
Version: 0.1.0 | ||
Title: Access to the List of Mammal Species of Colombia | ||
Version: 0.2.1 | ||
Authors@R: | ||
c( | ||
person("Diego J.", "Lizcano", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-9648-0576")) | ||
Date: 2024 | ||
comment = c(ORCID = "0000-0002-9648-0576")), | ||
person("Baltazar", "González", , "[email protected]", role = c("ctb"), | ||
comment = c(ORCID = "0000-0001-5805-8107")), | ||
person("Alejandra", "Bonilla-Sánchez", , "[email protected]", role = c("ctb"), | ||
comment = c(ORCID = "0000-0003-0803-5884")) | ||
) | ||
Date: 2024-03-28 | ||
Maintainer: Diego J. Lizcano <[email protected]> | ||
Description: Allows easy access to the data found in the species list featured | ||
in the renowned "Ramírez-Chaves, et al. 2021. Checklist of the Mammals | ||
(Mammalia) of Colombia”. Mammalogy Notes 7(2),253. | ||
<https://doi.org/10.47603/mano.v7n2.253>. This publication stands as | ||
<doi:10.47603/mano.v7n2.253>. This publication stands as | ||
one of Colombia's most comprehensive reviews of mammal diversity. The | ||
dataset incorporates detailed species accounts and has been | ||
meticulously structured for effortless utilization within the R | ||
environment. | ||
License: MIT + file LICENSE | ||
URL: https://github.com/dlizcano/mamalcol, | ||
URL: | ||
https://github.com/dlizcano/mammalcol, | ||
https://dlizcano.github.io/mammalcol/ | ||
BugReports: https://github.com/dlizcano/mammalcol/issues | ||
Depends: | ||
R (>= 2.10) | ||
Imports: | ||
ggplot2, | ||
magrittr | ||
magrittr, | ||
Suggests: | ||
dplyr, | ||
finch, | ||
|
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,7 +1,18 @@ | ||
# mammalcol 0.2.1 | ||
|
||
* Added new option to function mammalmap() to retrieve the ggplot object and select if want the legend or not, as suggested by Baltazar González. | ||
* Some typos corrected. | ||
* Contributors Baltazar González y Alejandra Bonilla-Sánchez added. | ||
|
||
|
||
# mammalcol 0.2.0 | ||
|
||
* Added sp_by_depto() function | ||
|
||
# mammalcol 0.1.0 | ||
|
||
* Initial CRAN submission. | ||
* Added vignettes | ||
* Added search_mammalcol() function | ||
* Added mammalmap() function | ||
* Added sp_by_depto() function | ||
|
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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
|
||
#' Retrieve Data from the List of the Mammals of Colombia | ||
#' | ||
#' This function takes a list of Mammal species names, searches for their data in | ||
#' the MammalCol pacakage dataset, and returns a data frame containing the relevant | ||
#' information for each species. | ||
#' | ||
#' The function allows fuzzy matching for species names with a maximum | ||
#' distance threshold to handle potential typos or variations in species names. | ||
#' | ||
#' @param splist A character vector containing the names of the species to search for. | ||
#' @param max_distance The maximum allowed distance for fuzzy matching of species names. | ||
#' Defaults to 0.2. | ||
#' | ||
#' @return A data frame containing the retrieved information for each species. | ||
#' | ||
#' @examples | ||
#' | ||
#' splist <- c("Tapirus bairdii", "Tapirus pinchaque", "Tapirus terrestris", | ||
#' "Tapirus terrestris", "tapir terrestre", "Pudu mephistophiles") | ||
#' | ||
#' search_mammalcol(splist) | ||
#' | ||
#' @importFrom mammalcol taxon | ||
#' | ||
#' @export | ||
search_mammalcol <- function(splist, max_distance = 0.2) { | ||
# Defensive function here, check for user input errors | ||
if (is.factor(splist)) { | ||
splist <- as.character(splist) | ||
} | ||
# Fix species name | ||
splist_st <- standardize_names(splist) | ||
dupes_splist_st <- find_duplicates(splist_st) | ||
|
||
if(length(dupes_splist_st) != 0 ){ | ||
message("The following names are repeated in the 'splist': ", | ||
paste(dupes_splist_st, collapse = ", ")) | ||
} | ||
splist_std <- unique(splist_st) | ||
|
||
# create an output data container | ||
output_matrix <- matrix(nrow = length(splist_std), ncol = 21) # two more | ||
colnames(output_matrix) <- c("name_submitted", | ||
names(taxon), | ||
"Distance") | ||
|
||
# loop code to find the matching string | ||
|
||
for (i in seq_along(splist_std)) { | ||
# Standardise max distance value | ||
if (max_distance < 1 & max_distance > 0) { | ||
max_distance_fixed <- ceiling(nchar(splist_std[i]) * max_distance) | ||
} else { | ||
max_distance_fixed <- max_distance | ||
} | ||
|
||
# fuzzy and exact match | ||
matches <- agrep(splist_std[i], | ||
taxon$scientificName, # base data column | ||
max.distance = max_distance_fixed, | ||
value = TRUE) | ||
|
||
# check non matching result | ||
if (length(matches) == 0) { | ||
row_data <- rep("nill", 19) # number of columns | ||
} | ||
else if (length(matches) != 0){ # match result | ||
dis_value <- as.numeric(utils::adist(splist_std[i], matches)) | ||
matches1 <- matches[dis_value <= max_distance_fixed] | ||
dis_val_1 <- dis_value[dis_value <= max_distance_fixed] | ||
|
||
if (length(matches1) == 0){ | ||
row_data <- rep("nill", 19) # number of columns | ||
} | ||
else if (length(matches1) != 0){ | ||
row_data <- as.matrix(taxon[taxon$scientificName %in% matches1,]) | ||
} | ||
} | ||
|
||
# distance value | ||
if(is.null(nrow(row_data))){ | ||
dis_value_1 <- "nill" | ||
} else{ | ||
dis_value_1 <- utils::adist(splist_std[i], row_data[,2]) | ||
} | ||
|
||
output_matrix[i, ] <- | ||
c(splist_std[i], row_data, dis_value_1) | ||
} | ||
|
||
# Output | ||
output <- as.data.frame(output_matrix) | ||
# rownames(output) <- NULL | ||
output <- output[,-2]# delete the id column | ||
return(output[output$scientificName != "nill",]) | ||
} | ||
|
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
Binary file not shown.
Oops, something went wrong.