iNaturalist User Trends with R

Hello fellow iNatters!

I’m just finishing up a Data Science for Biology course at UMASS Boston, and as the final project had to make an interactive web app with R. I ended up creating an app that, given an iNaturalist username, downloads the users observation data set and generates a number of visualizations, tables, and maps regarding their usage of iNat. The app has really been a hit among the iNat users on UMASS Boston’s Biology faculty, so I thought I share it with the community. Enjoy!

The app: https://jonathanlayman001.shinyapps.io/iNaturalist_user_trends/

P.S. may take a few minutes to load the visualizations depending on how many observations a user has. I also put a cap at 10,000 observations for performance, so if you have more than that this only uses your last 10k.

Jonathan Layman
Medford, Massachusetts
UMASS Boston Biology class of 2020

12 Likes

Oops, accidentally deleted. Just was saying, that it is very cool and thanks for sharing! One problem though, I keep getting an error (“ An error has occurred. Check your logs or contact the app author for clarification.”) when I go to the “Top Species” tab.

I just ran your username through the app, and while it took a minute to load, the data table in the top species tab loaded just fine. It may be that shinyapps.io had a momentary issue.

I just got an error as well. Also, is there a way to know that it’s working or do you simply wait to see if the data appears?

1 Like

I also received the error message after trying multiple people’s usernames. The only time there isn’t an error is when I use @jlayman’s name.

1 Like

If you run into error messages, try reopening the app; I believe that this is a shinyapps issue due to the amount of traffic. Shinyapps is by no means a perfect platform.
@zorrosidekick got your errors after the first try, but the app worked for your username after I restarted it.

This is really cool! Thanks jlayman.

I thought the most interesting thing was the “month” graph. This month so far I’ve been feeling really bogged down, suddenly too busy to do as much observing as I’d like… and now I see that according to my stats I always have a May slump! March and April are really high, June-July-August-September really high, but May is just low. Must be May is always my spring “crunch time” for non-iNat things. There’s also a noticeable spike in December- must be when the cabin fever really hits.

That is really cool

there may be more efficient ways to collect user stats than to aggregate / visualize after downloading a user’s entire set of observations, especially if the user has a lot of observations. i think each of the things you’re showing can be accomplished via specific API endpoint (http://api.inaturalist.org/v1/docs/):

  • Major Taxa – do a Get Observations request for each iconic taxon, returning just one record for each request with only the id, and then use the total_results value from each result set.
  • Top Species – use the Get Observations Species Counts endpoint
  • Quality Grade – do a Get Observations request for each quality grade, returning just one record for each request with only the id, and then use the total_results value from each result set.
  • Month – use the Get Observations Histogram endpoint
  • Map – use the Observations Tiles set of your choice, plus the associated UTFGrid if you want to be able to show associated details when clicking on a marker.

what you created may be a good learning exercise, and it may work for many use cases, but you may want to consider making it more efficient if you find that other people start using it a lot.

3 Likes

This is great! Thanks Jonathon. One thing though, is it possibly to make it so it shows your most ID’d organisms too?

Using this tool you can see how the stay at home order has changed my observation trends…

4 Likes

@pisum This was for a class on programming with R. The package for interfacing with iNaturalist and getting data, rinat, is still being developed, and currently can’t do any of those things outright- hence my brute force approach of downloading all observations and manipulating the data afterwards to achieve my objectives.

1 Like

@abersbird bird The R package for handling iNaturalist data, rinat, currently doesn’t have the ability to access identification data, so I wouldn’t be able to do so without figuring out how to use the API.

i’m not an R user myself, but i would guess it should be fairly straightforward to get data from the iNat API without rinat. if you figure out the basic process for that, i think that would open up a lot of possibilities for getting data from iNat, as well as other sources. this may help guide you down that path, if you’re interested: https://datascienceplus.com/accessing-web-data-json-in-r-using-httr/ or https://blog.exploratory.io/working-with-json-data-in-very-simple-way-ad7ebcc0bb89 or http://zevross.com/blog/2015/02/12/using-r-to-download-and-parse-json-an-example-using-data-from-an-open-data-portal/.

UPDATE: actually, i just remembered something. here’s some code that loarie posted in another thread that shows exactly how to pull data from the histogram API endpoint and generate a graph:
https://forum.inaturalist.org/t/1m-observations-this-month/2582/4.

5 Likes

Just to clarify – rinat is apparently no longer being developed. CRAN dropped the rinat package in January due to lack of response from the developers (see here). Looking at the rinat GitHub page (github.com/ropensci/rinat), there’s been almost no work done on it since last summer.

4 Likes

jlayman - This is very cool. Thank you!

1 Like

not user stats related, but here’s another example of R code leveraging the iNaturalist API: https://forum.inaturalist.org/t/what-things-are-misidentified-as-large-milkweed-bug/12571/4.

3 Likes

Does this work with firefox? I load the page, leave the default username, click in that field, hit enter, and nothing happens.

Looks like it behaves the same way in chrome.

Okay, that’s what it does when it’s working. You enter a user name, hit enter, and it does nothing, giving no hint of whether or not it’s working, for a long time. And then you get graphs and stuff. Some kind of loading / processing indication would be nice.

1 Like