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

Fixed species_family to return latest db version #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 37 additions & 23 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
Package: rFishTaxa
Type: Package
Package: rFishTaxa
Title: R Interface to 'Eschmeyer's Catalog of Fishes'
Version: 0.1.0
Date: 2022-09-08
Authors@R: c(person(given = "Liuyong", family = "Ding", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID="0000-0002-5490-182X")),
person(given = "Zhixin", family = "Zhang", email = "[email protected]", role = "ctb")
)
Authors@R:
c(person(given = "Liuyong",
family = "Ding",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-5490-182X")),
person(given = "Zhixin",
family = "Zhang",
role = "ctb",
email = "[email protected]"))
Maintainer: Liuyong Ding <[email protected]>
Description: `Eschmeyer's Catalog of Fishes` <https://www.calacademy.org/scientists/projects/catalog-of-fishes> is the authoritative reference for taxonomic fish names, featuring a searchable online database. This package helps users to query valid taxonomic fish information for biodiversity estimates, conservation issues, etc.
Depends: R (>= 4.0.0)
Description: `Eschmeyer's Catalog of Fishes`
<https://www.calacademy.org/scientists/projects/catalog-of-fishes> is
the authoritative reference for taxonomic fish names, featuring a
searchable online database. This package helps users to query valid
taxonomic fish information for biodiversity estimates, conservation
issues, etc.
License: Artistic-2.0
URL: https://otoliths.github.io/rFishTaxa/
BugReports: https://github.com/Otoliths/rFishTaxa/issues
Depends:
R (>= 4.0.0)
Imports:
httr,
tibble,
magrittr,
xml2,
dplyr,
stringr,
rvest,
janitor
dplyr,
httr,
janitor,
magrittr,
rvest,
stringr,
tibble,
tidyr,
xml2
Suggests:
utils,
testthat,
rmarkdown,
devtools,
knitr,
prettydoc,
devtools
rmarkdown,
testthat,
utils
VignetteBuilder:
knitr,
knitr,
rmarkdown
License: Artistic-2.0
URL: https://otoliths.github.io/rFishTaxa/
BugReports: https://github.com/Otoliths/rFishTaxa/issues
Encoding: UTF-8
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ importFrom(stringr,str_sub)
importFrom(stringr,str_trim)
importFrom(tibble,as_tibble)
importFrom(tibble,enframe)
importFrom(tidyr,fill)
importFrom(utils,browseURL)
importFrom(xml2,read_html)
importFrom(xml2,xml_find_all)
Expand Down
26 changes: 24 additions & 2 deletions R/species_family.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#' @importFrom utils browseURL
#' @importFrom janitor clean_names
#' @importFrom dplyr filter
#' @importFrom dplyr mutate
#' @importFrom tidyr fill
#' @details See for website \url{https://researcharchive.calacademy.org/research/ichthyology/catalog/SpeciesByFamily.asp} details.
#' @references \url{https://github.com/curso-r/lives/blob/6e042cf5f0bae0d957ff487a39b6601ac6f514ea/drafts/20210915_webscraping_ichthyology.R}
#' @examples
Expand Down Expand Up @@ -61,8 +63,28 @@ species_family <- function(){
rvest::html_table() %>%
janitor::clean_names() %>%
dplyr::filter(class != "Totals")
r <- readRDS(paste0(system.file("extdata",package = "rFishTaxa"),"/","db_2022_09.rds"))
return(tibble::as_tibble(r))
result %>%
dplyr::mutate(order = ifelse(endsWith(order, "formes") | endsWith(order, "*"),
order,
NA),
class = ifelse(is.na(available_genera) & is.na(order),
class,
NA),
# "Percalates-clade" among families as of 6 February 2024
family = ifelse(endsWith(family, "idae") | endsWith(family, '-clade"'),
family,
NA),
subfamily = ifelse(!is.na(available_genera) & is.na(family),
subfamily,
NA)
# subfamily = ifelse(endsWith(subfamily, "inae") | endsWith(subfamily, " sedis"),
# subfamily,
# NA)
) %>%
tidyr::fill("class", "order", "family") %>%
dplyr::filter(!is.na(available_genera))
# r <- readRDS(paste0(system.file("extdata",package = "rFishTaxa"),"/","db_2022_09.rds"))
# return(tibble::as_tibble(r))
}else{
cat("Error request - the parameter query is not valid")
browseURL(url)
Expand Down