Yet another PaperJS experiment. This one generates
Sparklines. It simply looks for canvases matching a specific CSS selector (“canvas.sparkler” by default), and draws a chart based on JSON-formatted data in the data-data attribute. Here, I’m displaying some unemployment data from Quandl.
What it’s doing: Each “node” has a “belief” that matches its hue, represented
as an angle between 0 and 359 degrees. Every 25 frames (once a second or so), a node is chosen at random and given
a choice whether to speak; if it does (this is represented by a fading circle expanding from the node). Every other
node has a chance to hear the speaking node based on the distance between the speaker and the listener–the farther
you are from the speaker, the less likely you are to hear.
Once a node does hear another node, it will only care about what it’s hearing under one of two conditions:
The hearer’s beliefs (i.e. color) are similar to the speakers, in which case the hearer’s beliefs will move slightly
closer to the speaker’s; or
The hearer’s beliefs are very different from the speakers, and its beliefs will move even further away from the
In either case, there is a small chance the hearer will “subscribe” to the speaker, which adds a line between the two and
means the hearer will always hear announcements from that speaker.
NB: This isn’t designed–at least in this incarnation–to be a realistic simulation of anything. It’s another
experiment with PaperJS.
While migrating my blog recently from WordPress to Jekyll, I looked for easy ways to post RMarkdown documents to my blog. I ended up developing two options of my own (available on GitHub):
jekyll.R provides two R functions to let you add posts or drafts to your Jekyll blog direct from the RStudio console, by knit()ing an .Rmarkdown document into markdown with the YAML “front-matter” Jekyll expects. This is probably the best option for blogs.
rmarkdown_converter.rb is a Jekyll plugin that provides an Rmarkdown “converter”. This lets write your posts in RMarkdown and save them in your site’s _drafts or _posts directory with the extension Rmd or Rmarkdown, just like you normally post standard markdown documents.
The downside here is that changes to your R environment (you get a new computer and don’t reinstall all of the packages you had before, you upgrade R and one of the packages you used to use is no longer supported, etc.) can make it impossible to build your blog (or at least some posts). It might be more useful for some non-blog sites.
I’ve been experimenting lately with Paper.js, “The Swiss Army Knife of Vector Graphics Scripting.”
My first effort is below, an interactive (try selecting lines by clicking and dragging) parallel coordinate plot.
The plot below is displaying the state.x77 dataset
built in to R; I’ll think of something more interesting to display with it eventually.
I've been asked to look into doing some kind of analysis of this Sexual Health Rankings data. The data's available as a spreadsheet providing data by state, so I'm using my preliminary, check-this-stuff-out phase, as an opportunity to check out R's xslx package and Stately.
xslx allows you to read and write Excel workbooks from R. Below, I use the high-level read.xslx function to read blocks of cells from worksheets as dataframes, which is quick and easy to work with.
Another Shiny app, this one taking data on U.S. unemployment from Quandl and generating graphs and tables describing it. I was mainly trying to update my Shiny knowledge based on the new(-ish) version 0.4.
This app is on GitHub, so it should be possible to run it with:
We have here 1530 individual plays, with 1274 unique tracks. That already sounds like more variety than Toronto’s Virgin Radio offers–most songs on RP were only played once. This makes the kind of chart Matt did for Virgin Radio a little boring here:
It could be interesting to do this kind of analysis with soma fm. Their stations–at least all the ones I’ve checked–post their playlists to Twitter, which gives us a built-in API for importing their playlist feeds. It might also be interesting (or it might not) to use Last.fm’s API to pull a list of user-contributed tags for each song, and analyze radio stations that way (or use the data to recommend radio stations to last.fm users).