24 April, 2015

Foraging for morels

We geeks pursue atavism with data.

And R, of course.

Ideas for modeling morels with R

We can scrape the morel sightings postings to get approximate location and dates.

But what else?


  • Live in substrates like wood and soil and other organic matter
  • Fruiting is usually annual and sensitive to ground temperature and moisture
  • Fungi often form symbiotic relationships with plants; Morels often live among elm, tulip and apple trees

The public owns satellites that almost continuously measure values like vegetation cover, temperature, …

Building blocks of a model?

  • Web-scraped historical morel sighting data
  • NASA MODIS spectral radiometry data
  • NASA land surface temperature data

sightings \(\sim\) temperature \(+\) spectral data \(+ \cdots\)

R is spectacularly well-equipped for this

  • MODIS package
  • rgdal and sp packages
  • Comprehensive set of spatial statistics packages
  • And of course lots of modeling methods

Leaflet visualization from R

Plot our fanciful morel model prediction for March 6 of this year (2015) with leaflet. It's kind of like Zillow for foragers.

Click here to view the interactive output of this http://illposed.net/nycr2015/leaflet/

ap = addTiles(leaflet())
map = setView(map, -79.4, 35.66, zoom = 7)
map = add_quantile(predictions, 0.95, 0.25)
map = add_quantile(predictions, 0.98, 0.25)
map = add_quantile(predictions, 0.99, 0.25)

Get your bling on visualization with the threejs package for R

Plot our fanciful model prediction globally for old data from last May.

Click here for an interactive version of this output http://illposed.net/nycr2015/globejs/

globejs(lat=x$lat, long=x$long, val=prediction,
        color=col, pointsize=0.5, atmosphere=TRUE)

htmlwidgets: elegant, systematic integration of web presentation technologies and R

Ramnath Vaidyanathan and J.J. Allaire

Why web?

  • Pervasive
  • Portable
  • Herds of developers
  • Mind-blowing awesomeness

D3.js (Mike Bostock), threejs (Ricardo Cabello a.k.a. mrdoob), …

That's great, but

what about us regular statisticians and economists and biologists and data scientists and foragers?

That's where htmlwidgets comes in

Create rich, interactive visualizations,

written in R with simple, natural syntax,

acting like normal R graphics,

and fast.

Use anywhere

  • Integrated RStudio viewer
  • R markdown documents (like this one)
  • Shiny apps
  • Command-line R (via browser)

Everybody wins

For us scientists and statisticians: For you viz gurus:

Enables cutting edge visualization using familiar tools! Puts your libraries in the hands of lots of smart people!

More (serious) examples

Association Rules Explorer

A Shiny app built with the DT and networkD3 widgets to explore rules mined by the arules package with the apriori algorithm.

You can download this shiny app R code and run it yourself from http://illposed.net/arules_explorer.R