What can a kaka, a kakapo, an European rabbit and a grey heron have in
common? Well, they might co-habit in the bookshelf of an R user, since
theyâ€™re all animals on the covers of popular R books: â€œR
Packagesâ€�, â€œR for Data
Scienceâ€�, â€œText mining with
Râ€� and â€œEfficient R
programmingâ€�, respectively.
Their publisher, Oâ€™Reilly, has now based its brand on covers featuring
beautiful gravures of animals.
Recently, while wondering what the name of R for Data Science bird was
again (I thought it was a kea!), I was thrilled to find the whole
Oâ€™Reilly menagerie, i.e.Â a list of
books and corresponding animals! The website also features a link to â€œA
short history of the Oâ€™Reilly
animalsâ€�
that was an amazing read. In it was noted that â€œThe animals are in
trouble.â€�, with a few examples of endangered species. It inspired me to
actually try and assess the conservation status of Oâ€™Reilly animals
using responsible webscraping, taxonomic name resolving and IUCN Redlist
API queryingâ€¦
Scraping the menagerie: an utter delight!
I had a great time webscraping the menagerie, not only thanks to my now
reasonable experience doing such things, but also thanks to
my using the wonderful polite package for
webscraping, that makes me feel
so good about myself. Read more about this package in my previous
post.
the webpage having really good structured html with specific
classes.
The menagerie is divided into pages of 20 books, so I mapped over all
possible offsets up to the number of animals indicated on the website,
1227.
library(&quot;magrittr&quot;)
home_url %
rvest::html_text() -__ animal_names
tibble::tibble(book = book_titles,
animal = animal_names)
}
no_animals %
dplyr::filter(stringr::str_detect(animal, &quot;[Ss]almon&quot;)) %__%
knitr::kable()
book
animal
Values, Units, and Colors
Salmon
CSS Text
Salmon
CSS Fonts
Salmon
Selectors, Specificity, and the Cascade
Salmon
Transitions and Animations in CSS
Salmon2
I have no idea what trait of salmons make them good at design, other
than my not sharing that trait with them. When my friend Adrien and I
wrote a (non Oâ€™Reilly)
book
years ago, we selected a frog for the cover based on its being pretty,
which is much less cool than Oâ€™Reilly branding!
From animals common names to scientific names?
Now, youâ€™ll have noticed the names of animals are written in English. My
ultimate goal being the querying of IUCN Red List API, and this API only
accepting scientific names (contrary to the website of the same
organization), I needed to resolve the common names to scientific names.
This is a hard problem! My strategy here was:
Cleaning the names a bit to remove the parts after â€œakaâ€� for
instance.
clean %
stringr::str_remove_all(&quot;\\,.*&quot;) %__%
stringr::str_remove_all(&quot;\\(.*&quot;) if(semiclean == &quot;12-Wired Bird of Paradise&quot;){
semiclean