Adam T. Bradley

The study of money is the root of all evil

All these findings correspond with a substantial body of research in the economic literature, which, with the help of surveys, laboratory experiments, as well as field experiments showed that those who learn about markets (economists) or act in markets (businessmen) are lacking in … ‘pro-social behavior’ … I also use corruption as a proxy to show whether there are any differences in pro-social behavior between economists and non-economists, but unlike them, I observe behavior outside the artificial situation of a laboratory. By analyzing real world data of the U.S. Congress, I found that politicians holding a degree in economics are significantly more prone to engage in corrupt practices.

René Ruske, “Does Economics Make Politicians Corrupt? Empirical Evidence from the United States Congress”

Social Network Simulation with PaperJS

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:

  1. 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
  2. The hearer’s beliefs are very different from the speakers, and its beliefs will move even further away from the speaker’s.

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.

Word Hail

This is a minor experiment with Paper.js, made while I (re-)teach myself to animate color and movement. (Click through to view.)

RMarkdown and Jekyll

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.

This code borrows heavily from the sample converter on the Jekyll plugins documentation page and this post by Simon Elliston Ball.

Stately and sexual health


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.

Stately is a quick and easy (and fun) way to draw simple choropleth maps of the US. It's implemented as a font and some CSS; to use it in a web page, you just create a list with each letter A-Z and a-y and style the elements as needed. I've written an R script that generates the html you need to generate a map with Stately.

More Shiny

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:

runGitHub(‘shiny_unemployment’, ‘atbradley’)