Closed jmschuster closed 1 year ago
Thanks for your report. Please see if you can provide a reprex example so I can help make sure I'm testing what you're testing.
Based on the information you provided I was able to construct this example, it doesn't have all NAs though:
library(rfishbase)
fish <- c("Clupea pallasii", "Oncorhynchus keta", "Oncorhynchus kisutch",
"Oncorhynchus tshawytscha", "Salvelinus malma", "Oncorhynchus mykiss",
"Oncorhynchus clarkii", "Sardinops sagax", "Engraulis mordax")
fields <- c("Fresh", "Brack", "Saltwater", "DemersPelag", "AnaCat")
species(fish, fields = fields)
#> Joining, by = c("Subfamily", "GenCode", "FamCode")
#> Joining, by = "FamCode"
#> Joining, by = c("Order", "Ordnum", "Class", "ClassNum")
#> Joining, by = c("Class", "ClassNum")
#> # A tibble: 9 × 5
#> Fresh Brack Saltwater DemersPelag AnaCat
#> <int> <int> <int> <chr> <chr>
#> 1 1 1 1 pelagic-neritic non-migratory
#> 2 1 1 1 benthopelagic anadromous
#> 3 1 1 1 pelagic anadromous
#> 4 1 1 1 benthopelagic anadromous
#> 5 1 1 1 benthopelagic anadromous
#> 6 1 1 1 benthopelagic anadromous
#> 7 1 1 1 demersal anadromous
#> 8 0 0 1 pelagic-neritic oceanodromous
#> 9 0 0 1 pelagic-neritic <NA>
Created on 2022-12-08 with reprex v2.0.2
Are you still seeing something different if you copy-paste what I have above?
Thank you for your response! Your code worked, and it worked for all the species when manually copied into the 'fish' vector. This made me realize there's an issue with blank spaces between text strings in some of the species names. The blank space between genus and species was recognized for some species in the df, but not others, returning NAs...
This fixed the species text strings
df$Species_name <- gsub("\\s+"," ", df$Species_name)
and then the species() extraction worked perfectly. Thanks again!
Hello, I am trying to extract habitat info for a vector of 120 species using the function species() in rfishbase (4.0.0). However, trying to run species() for all 120 species returns mostly NA's. If I run species() for just 1-5 species in this format (below), there are no NAs... why does the extraction not work for the whole species list at once when the data is clearly there?
Extraction of few species (works):
species(c("Clupea pallasii", "Oncorhynchus keta"), fields = species_fields$habitat)
`
A tibble: 3 × 5
Fresh Brack Saltwater DemersPelag AnaCat