-
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
19 changed files
with
521 additions
and
17 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 |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
.Rhistory | ||
.RData | ||
.Ruserdata | ||
|
||
.travis.yml |
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
export(mammalmap) | ||
export(search_mammalcol) | ||
export(sp_by_depto) |
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,38 @@ | ||
#' distribution Dataset | ||
#' | ||
#' The distribution dataset comprises a data frame containing information | ||
#' regarding mammal species distribution documented in Colombia, sourced from the "List of the | ||
#' mammals of Colombia" compiled by Ramírez-Chaves 2021. It encompasses various | ||
#' details, including locality, source, threat status and appendix CITES of each species. | ||
#' The table is a variant of the distribution table from https://doi.org/10.15472/kl1whs | ||
#' | ||
#' @format A data frame with 548 rows and 8 columns: | ||
#' \describe{ | ||
#' \item{id}{id from original taxon table.} | ||
#' \item{locality}{Departamento were the mammal is present.} | ||
#' \item{countryCode}{Code for Colombia.} | ||
#' \item{establishmentMeans}{Is endemic?. Endémica=Yes} | ||
#' \item{threatStatus}{categorization previous to 2021} | ||
#' \item{appendixCITES}{Apendix form CITES} | ||
#' \item{source}{reference for distribution} | ||
#' \item{occurrenceRemarks}{region were the species occurs.} | ||
#' } | ||
#' | ||
#' | ||
#' @details This dataset is designed to provide users with comprehensive | ||
#' information about the mammal species found in Colombia, as documented | ||
#' by Ramírez-Chaves 2021. It is organized for easy access and utilization within | ||
#' the R environment. | ||
#' | ||
#' @seealso | ||
#' For more information about the "mammalcol" package and the data sources, visit | ||
#' the package's GitHub repository: \url{https://github.com/dlizcano/mammalcol} | ||
#' | ||
#' @references | ||
#' The dataset is based on the "List of the Mammals of Colombia" by Ramírez-Chaves 2021. | ||
#' | ||
#' @author | ||
#' Data compilation: Ramírez-Chaves 2021, Package implementation: Diego J. Lizcano | ||
#' | ||
#' @keywords dataset | ||
"distribution" |
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,54 @@ | ||
#' Mammal occurrence by departamento | ||
#' | ||
#' Find the mammal species that occur in a given departamento of Colombia | ||
#' | ||
#' @param states a character vector with one or more departamento names | ||
#' @param type type of matching to be used. \code{any} will return the mammal species that | ||
#' occur in any of the passed \code{states}. \code{only} matches mammal species that | ||
#' occur only in all provided (no more, no less) \code{states} and \code{all} matches | ||
#' mammal species that occur at least in all \code{states} passed. See examples. | ||
#' @param taxa optional character vector to match against the departamentos. Use the order name | ||
#' @export | ||
#' @return a data frame | ||
#' @examples | ||
#' \dontrun{ | ||
#' occ.any <- sp_by_depto(c("Arauca", "Norte de Santander"), type = "any") | ||
#' occ.only <- sp_by_depto(c("Norte de Santander"), type = "only") | ||
#' occ.all <- sp_by_depto(c("Arauca", "Norte de Santander"), type = "all") | ||
#' occ.taxa <- sp_by_depto(c("Arauca", "Norte de Santander"), type = "all", taxa = "Chiroptera") | ||
#' | ||
#' head(occ.any) | ||
#' head(occ.only) | ||
#' head(occ.all) | ||
#' head(occ.taxa) | ||
#' } | ||
#' | ||
sp_by_depto <- function(states, type = c("any", "only", "all"), taxa = NULL) { | ||
if (length(states) == 0) stop("Please provide at least one Colombian Departamento") | ||
type <- match.arg(type) | ||
states <- sort(states) | ||
# states <- paste("BR-", states, sep = "") | ||
if (length(states) == 0) stop("Please provide at least one Colombian Departamento") | ||
# res <- lapply(occurrences, match, states) | ||
if (type == "any") { | ||
#res <- lapply(res, function(x) any(!is.na(x))) | ||
res <- subset(distribution, grepl(paste(states, collapse = "|"), locality)) | ||
} | ||
if (type == "only") { | ||
res <- subset(distribution, grepl(paste("^", paste(states, collapse = "\\|"), "$", sep = ""), locality)) | ||
} | ||
if (type == "all") { | ||
res <- subset(distribution, grepl(paste(states, collapse = ".*"), locality)) | ||
} | ||
# res <- distribution[unlist(res), ] | ||
if (nrow(res) == 0) { | ||
return(NA) | ||
} | ||
if (is.null(taxa)) { | ||
merge(taxon[, c("scientificName", "family", "order", "id")], res[, c("id", "locality")], by = "id")[,-1] | ||
# removes id | ||
} else { | ||
merge(taxon[taxon$order %in% taxa, c("scientificName", "family", "order", "id" )], res[, c("id", "locality")], by = "id")[,-1] | ||
# removes id | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.