James-Thorson-NOAA / FishLife

Estimate fish traits for all marine fish species globally
https://james-thorson-noaa.github.io/FishLife/
GNU General Public License v3.0
45 stars 12 forks source link

Update Match_species.R #10

Closed DanOvando closed 5 years ago

DanOvando commented 5 years ago

Seems like rfishbase::fishbase switched to a tibble (rfishbase version 2.99). Running tolower on a column of a data_frame indexed by [,'Genus'] does some strange stuff since tolower takes a vector and [,"Genus"] on a tibble returns a data_frame. Simple fix to just using tolower(rfishbase::fishbase$Genus)/ tolower(rfishbase::fishbase$Species) instead (and using $ is actually a bit faster for data_frames, though doesn't matter much in this context)

tolower(rfishbase::fishbase[1:10,"Genus"])
#> [1] "c(\"abyssocottus\", \"abyssocottus\", \"abyssocottus\", \"asprocottus\", \"asprocottus\", \"asprocottus\", \"asprocottus\", \"asprocottus\", \"asprocottus\", \"asprocottus\")"

tolower(rfishbase::fishbase$Genus[1:10])
#>  [1] "abyssocottus" "abyssocottus" "abyssocottus" "asprocottus" 
#>  [5] "asprocottus"  "asprocottus"  "asprocottus"  "asprocottus" 
#>  [9] "asprocottus"  "asprocottus"

Created on 2018-10-23 by the reprex package (v0.2.1)