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

common_to_sci for other languages #275

Open
epistecius opened this issue Jan 15, 2024 · 1 comment
Open

common_to_sci for other languages #275

epistecius opened this issue Jan 15, 2024 · 1 comment

Comments

@epistecius
Copy link

epistecius commented Jan 15, 2024

Hi,

can't seem to get the command common_to_sci to work for other languages.

common_to_sci( "Plötze", Language = "German" )

common_to_sci( "Blankvoorn", Language = "Dutch" )

common_to_sci( "Gardon", Language = "French" )

all deliver zero results.

And,
common_to_sci( "Roach", Language = "German" )

Delivers all roaches in the english db, irrepsective of the language indicated.

I'm using rFishbase Version 4.1.2. on R version 4.2.2 (2022-10-31 ucrt), platform x86_64-w64-mingw32

Thanks,
David

@fishheadmaggus
Copy link

There are two bugs in common_to_sci(): (1) "Language" is not forwarded to get_comnames(), (2) the function name in line 7 must be enquote() instead of enquo(). This here seems to work from the R command line:

common_to_sci <- function(x, Language = "English", server = getOption("FISHBASE_API", "fishbase"), 
                          version = rfishbase:::get_latest_release(), db = rfishbase:::default_db()) 
{
  comnames <- rfishbase:::get_comnames(lang = Language, server, version, db) %>% dplyr::collect()
  subset <- purrr::map_dfr(x, function(y) {
    y <- stringr::str_to_lower(y)
    y <- enquote(y)
    dplyr::filter(comnames, grepl(!!y, stringr::str_to_lower(ComName)))
  })
  subset
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants