ropensci / rfishbase

R interface to the fishbase.org database
https://docs.ropensci.org/rfishbase
109 stars 40 forks source link

Impossible to get available information for some species #236

Closed Lucie-KCZ closed 1 year ago

Lucie-KCZ commented 2 years ago

Hi,

I am trying to get trophic information about a list of 411 European and North American freshwater fish species. Amongst those species, I have for instance the Atlantic Salmon (Salmo salar) but the functions diet() and ecology() don't return any value for this species. It happens for other species that, on the Fishbase website, are actually documented. I have checked the spelling and it is correct. I checked also using the validate_names() function which returns NA. I thought it was maybe because the list of species was too big but even if I am asking just for the Salmon, I still get a missing value while it works for other species (e.g., Abramis brama).

Thank you very much for your help and the time!

> (diet <- diet(species_list = 'Salmo salar', c('Species', 'Troph')))
# A tibble: 1 × 2
  Species     Troph
  <chr>       <dbl>
1 Salmo salar    NA
Session Info ```r ─ Session info ──────────────────────────────────────────────────────────────────────── setting value version R version 4.0.4 (2021-02-15) os macOS Big Sur 10.16 system x86_64, darwin17.0 ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz Europe/Berlin date 2021-10-29 ─ Packages ──────────────────────────────────────────────────────────────────────────── ! package * version date lib source P arkdb 0.0.14 2021-10-18 [?] CRAN (R 4.0.2) P assertthat 0.2.1 2019-03-21 [?] CRAN (R 4.0.2) P bit 4.0.4 2020-08-04 [?] CRAN (R 4.0.2) P bit64 4.0.5 2020-08-30 [?] CRAN (R 4.0.2) P blob 1.2.2 2021-07-23 [?] CRAN (R 4.0.2) P cachem 1.0.6 2021-08-19 [?] CRAN (R 4.0.2) P callr 3.7.0 2021-04-20 [?] CRAN (R 4.0.2) P cli 3.0.1 2021-07-17 [?] CRAN (R 4.0.2) P crayon 1.4.1 2021-02-08 [?] CRAN (R 4.0.2) P curl 4.3.2 2021-06-23 [?] CRAN (R 4.0.2) P DBI 1.1.1 2021-01-15 [?] CRAN (R 4.0.2) P dbplyr 2.1.1 2021-04-06 [?] CRAN (R 4.0.2) P desc 1.4.0 2021-09-28 [?] CRAN (R 4.0.2) P devtools * 2.4.2 2021-06-07 [?] CRAN (R 4.0.2) P dplyr 1.0.7 2021-06-18 [?] CRAN (R 4.0.2) P ellipsis 0.3.2 2021-04-29 [?] CRAN (R 4.0.2) P fansi 0.5.0 2021-05-25 [?] CRAN (R 4.0.2) P fastmap 1.1.0 2021-01-25 [?] CRAN (R 4.0.2) P fs 1.5.0 2020-07-31 [?] CRAN (R 4.0.2) P generics 0.1.0 2020-10-31 [?] CRAN (R 4.0.2) P gh 1.3.0 2021-04-30 [?] CRAN (R 4.0.2) P glue 1.4.2 2020-08-27 [?] CRAN (R 4.0.2) P hms 1.1.1 2021-09-26 [?] CRAN (R 4.0.2) P httr 1.4.2 2020-07-20 [?] CRAN (R 4.0.2) P jsonlite 1.7.2 2020-12-09 [?] CRAN (R 4.0.2) P lifecycle 1.0.1 2021-09-24 [?] CRAN (R 4.0.2) P magrittr 2.0.1 2020-11-17 [?] CRAN (R 4.0.2) P memoise 2.0.0 2021-01-26 [?] CRAN (R 4.0.2) P pillar 1.6.4 2021-10-18 [?] CRAN (R 4.0.2) P pkgbuild 1.2.0 2020-12-15 [?] CRAN (R 4.0.2) P pkgconfig 2.0.3 2019-09-22 [?] CRAN (R 4.0.2) P pkgload 1.2.3 2021-10-13 [?] CRAN (R 4.0.2) P prettyunits 1.1.1 2020-01-24 [?] CRAN (R 4.0.2) P processx 3.5.2 2021-04-30 [?] CRAN (R 4.0.2) P progress 1.2.2 2019-05-16 [?] CRAN (R 4.0.2) P ps 1.6.0 2021-02-28 [?] CRAN (R 4.0.2) P purrr 0.3.4 2020-04-17 [?] CRAN (R 4.0.2) P R6 2.5.1 2021-08-19 [?] CRAN (R 4.0.2) P Rcpp 1.0.7 2021-07-07 [?] CRAN (R 4.0.2) P readr 2.0.2 2021-09-27 [?] CRAN (R 4.0.2) P remotes 2.4.1 2021-09-29 [?] CRAN (R 4.0.2) renv 0.14.0 2021-07-21 [1] CRAN (R 4.0.2) P rfishbase * 3.1.9 2021-08-09 [?] CRAN (R 4.0.2) P rlang 0.4.12 2021-10-18 [?] CRAN (R 4.0.2) P rprojroot 2.0.2 2020-11-15 [?] CRAN (R 4.0.2) P RSQLite * 2.2.8 2021-08-21 [?] CRAN (R 4.0.2) P sessioninfo 1.1.1 2018-11-05 [?] CRAN (R 4.0.2) P stringi 1.7.5 2021-10-04 [?] CRAN (R 4.0.2) P stringr 1.4.0 2019-02-10 [?] CRAN (R 4.0.2) P testthat 3.1.0 2021-10-04 [?] CRAN (R 4.0.2) P tibble 3.1.5 2021-09-30 [?] CRAN (R 4.0.2) P tidyselect 1.1.1 2021-04-30 [?] CRAN (R 4.0.2) P tzdb 0.1.2 2021-07-20 [?] CRAN (R 4.0.2) P usethis * 2.1.3 2021-10-27 [?] CRAN (R 4.0.4) P utf8 1.2.2 2021-07-24 [?] CRAN (R 4.0.2) P vctrs 0.3.8 2021-04-29 [?] CRAN (R 4.0.2) P withr 2.4.2 2021-04-18 [?] CRAN (R 4.0.2) ```
cboettig commented 2 years ago

that is indeed unexpected. I cannot reproduce the bug, see my results below.

I suspect you have a corrupted local cache. Let's purge that using: fs::dir_delete(rfishbase:::db_dir()) and try again?

library(rfishbase); (diet <- diet(species_list = 'Salmo salar', c('Species', 'Troph')))
#> # A tibble: 15 × 2
#>    Species     Troph
#>    <chr>       <dbl>
#>  1 Salmo salar  3.2 
#>  2 Salmo salar  3.2 
#>  3 Salmo salar  3.2 
#>  4 Salmo salar  3.2 
#>  5 Salmo salar  3.2 
#>  6 Salmo salar  3.2 
#>  7 Salmo salar  3.2 
#>  8 Salmo salar  3.2 
#>  9 Salmo salar  4.43
#> 10 Salmo salar  4.5 
#> 11 Salmo salar  4.5 
#> 12 Salmo salar  4.5 
#> 13 Salmo salar  4.5 
#> 14 Salmo salar  4.5 
#> 15 Salmo salar  4.5

Created on 2021-10-29 by the reprex package (v2.0.1)

Lucie-KCZ commented 2 years ago

Really weird here but I actually rerun the the diet('Salmo salar') part before running the command you suggest and then, that happened:

> (diet <- diet(species_list = 'Salmo salar', c('Species', 'Troph')))
Importing /Users/lucie_kcz/Library/Application Support/org.R-project.R/R/rfishbase/diet_fb_2104.tsv.bz2 in 1000000 line chunks:
Rows: 7055 Columns: 40                                                                                               
── Column specification ──────────────────────────────────────────────────────────
Delimiter: "\t"
chr   (9): DietCode, SampleStage, April, July, September, C_Code, Locality, Re...
dbl  (26): StockCode, Speccode, DietRefNo, SampleSize, YearStart, YearEnd, Jan...
lgl   (2): Method, MethodType
dttm  (3): DateEntered, DateModified, DateChecked

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
    ...Done! (in 1.045721 secs)
Importing /Users/lucie_kcz/Library/Application Support/org.R-project.R/R/rfishbase/species_fb_2104.tsv.bz2 in 1000000 line chunks:
Rows: 35331 Columns: 101                                                                                             
── Column specification ──────────────────────────────────────────────────────────
Delimiter: "\t"
chr (63): SpecCode, Genus, Species, Author, FBname, PicPreferredName, PicPrefe...
dbl (36): SpeciesRefNo, FamCode, GenCode, SubGenCode, Fresh, Brack, Saltwater,...
lgl  (2): AmphibiousRef, Complete

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
    ...Done! (in 5.973944 secs)
Importing /Users/lucie_kcz/Library/Application Support/org.R-project.R/R/rfishbase/genera_fb_2104.tsv.bz2 in 1000000 line chunks:
Rows: 11863 Columns: 64                                                                                              
── Column specification ──────────────────────────────────────────────────────────
Delimiter: "\t"
chr  (35): GenCode, GenName, GenAuthorYear, GenAuthor, GenYear, GenInEx, GenCo...
dbl  (24): GenRefno, FamCode, DepthRangeShallow, FB_SppNb, CofF_SppNb, FoW_Spp...
lgl   (2): Brackish, Freshwater
dttm  (3): Dateentered, Datemodified, Datechecked

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
    ...Done! (in 1.287426 secs)
Importing /Users/lucie_kcz/Library/Application Support/org.R-project.R/R/rfishbase/families_fb_2104.tsv.bz2 in 1000000 line chunks:
Rows: 1288 Columns: 81                                                                                               
── Column specification ──────────────────────────────────────────────────────────
Delimiter: "\t"
chr  (50): FamCode, SortID, Family, AuthorYear, Qualification, CommonName, Fam...
dbl  (23): Species, SexualDimorphism, FossilRef, ValidGenera, Complete, Aspine...
lgl   (5): CAS_LIN, ZooBank_ID, CommonName_Chinese, CommonName_Chinese_u, Comm...
dttm  (3): DateEntered, DateModified, DateChecked

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
    ...Done! (in 0.368258 secs)
Importing /Users/lucie_kcz/Library/Application Support/org.R-project.R/R/rfishbase/orders_fb_2104.tsv.bz2 in 1000000 line chunks:
Rows: 113 Columns: 56                                                                                                
── Column specification ──────────────────────────────────────────────────────────
Delimiter: "\t"
chr  (35): Ordnum, Order, Synonym, CommonName, BodyShapeI, Brackish, Freshwate...
dbl  (12): OrderRefNo, SortNo, AuthorYear, Marine, FamCount, ClassNum, ComAncR...
lgl   (7): CAS_LIN, ZooBank_ID, DateChecked, CommonName_Spanish, CommonName_Ch...
dttm  (2): DateEntered, DateModified

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
    ...Done! (in 0.2096791 secs)
Importing /Users/lucie_kcz/Library/Application Support/org.R-project.R/R/rfishbase/classes_fb_2104.tsv.bz2 in 1000000 line chunks:
Rows: 14 Columns: 16                                                                                                 
── Column specification ──────────────────────────────────────────────────────────
Delimiter: "\t"
chr (7): Class, CommonName, BodyShapeI, WaterSalinity, SuperClass, Subclass, R...
dbl (5): ClassNum, ClassRefNo, SortNo, Synonym, SpeciesCount
lgl (4): AuthorYear, CAS_LIN, ZooBank_ID, TS

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
    ...Done! (in 0.1069829 secs)
Joining, by = c("Subfamily", "GenCode", "FamCode")
Joining, by = "FamCode"
Joining, by = c("Order", "Ordnum", "Class", "ClassNum")
Joining, by = c("Class", "ClassNum")
# A tibble: 15 × 2
   Species     Troph
   <chr>       <dbl>
 1 Salmo salar  3.2 
 2 Salmo salar  3.2 
 3 Salmo salar  3.2 
 4 Salmo salar  3.2 
 5 Salmo salar  3.2 
 6 Salmo salar  3.2 
 7 Salmo salar  3.2 
 8 Salmo salar  3.2 
 9 Salmo salar  4.43
10 Salmo salar  4.5 
11 Salmo salar  4.5 
12 Salmo salar  4.5 
13 Salmo salar  4.5 
14 Salmo salar  4.5 
15 Salmo salar  4.5 

And now it works perfectly.. I didn't do anything specific since my post. Thanks for taking the time though and have a good week!