(cf. mt 11:28-30)
(cf. mt 11:28-30)
Posted at 10:02 AM in Music, Religion | Permalink | Comments (0) | TrackBack (0)
Posted at 10:14 AM | Permalink | Comments (0) | TrackBack (0)
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.
First, import some libraries and grab the files I need:
library(RColorBrewer)
library(xlsx)
library(plyr) #I'm using join().
library(devtools)
library(httr)
library(xtable) #To print dataframes as HTML.
source_url("https://gist.github.com/atbradley/5505405/raw/bd712ac911dd4c4e33ed5c48cf08f7aa5821c81f/statelify.R")
stately <- read.csv(text = content(GET("https://gist.github.com/atbradley/5505405/raw/ee458ae140ad95f8d4813276c33d7d23a377b9d9/stately.csv")))
fn <- "shr2012.xslx"
writeBin(content(GET("http://www.sexualhealthrankings.com/pubfiles/SexualHealthRankings_2012_Data.xlsx")),
fn)
Then define some colors:
darkRed <- '#3B0B0B'
scorePalette <- brewer.pal(11, 'RdYlGn')
aidsPalette <- rev(heat.colors(15))
#Don't want the alpha channel.
aidsPalette <- gsub('.{2}$', '', aidsPalette)
Now read the weighted scores from the SHR workbook and map them:
weightedScores <- read.xlsx(fn, 1, rowIndex = 3:53, colIndex = 1:3, header = F)
score.cols <- c("rank", "stateName", "score")
colnames(weightedScores) <- score.cols
scores <- weightedScores$score
scores <- scores + abs(min(scores))
weightedScores$state <- tolower(weightedScores$stateName)
num.colors <- length(scorePalette)
score.color.indices <- as.integer(1 + (scores/max(scores) * (num.colors - 1)))
weightedScores$color <- scorePalette[score.color.indices]
score.map <- statelify(join(stately, weightedScores))
cat(score.map)
And print the data we used to make that map:
| rank | stateName | score | state | color |
|---|---|---|---|---|
| 1.00 | Vermont | 1.24 | vermont | #006837 |
| 2.00 | Connecticut | 0.99 | connecticut | #66BD63 |
| 3.00 | New Hampshire | 0.96 | new hampshire | #66BD63 |
| 4.00 | New Jersey | 0.90 | new jersey | #66BD63 |
| 5.00 | Massachusetts | 0.88 | massachusetts | #66BD63 |
| 6.00 | Maine | 0.79 | maine | #66BD63 |
| 7.00 | Iowa | 0.73 | iowa | #A6D96A |
| 8.00 | Minnesota | 0.73 | minnesota | #A6D96A |
| 9.00 | Hawaii | 0.67 | hawaii | #A6D96A |
| 10.00 | Wisconsin | 0.65 | wisconsin | #A6D96A |
| 11.00 | Oregon | 0.65 | oregon | #A6D96A |
| 12.00 | Washington | 0.64 | washington | #A6D96A |
| 13.00 | Maryland | 0.58 | maryland | #A6D96A |
| 14.00 | New York | 0.47 | new york | #D9EF8B |
| 15.00 | Colorado | 0.37 | colorado | #D9EF8B |
| 16.00 | Delaware | 0.34 | delaware | #D9EF8B |
| 17.00 | Wyoming | 0.30 | wyoming | #FFFFBF |
| 18.00 | Montana | 0.30 | montana | #FFFFBF |
| 19.00 | Rhode Island | 0.27 | rhode island | #FFFFBF |
| 20.00 | District of Columbia | 0.23 | district of columbia | #FFFFBF |
| 21.00 | Nebraska | 0.16 | nebraska | #FFFFBF |
| 22.00 | Pennsylvania | 0.15 | pennsylvania | #FFFFBF |
| 23.00 | Utah | 0.15 | utah | #FFFFBF |
| 24.00 | Virginia | 0.13 | virginia | #FFFFBF |
| 25.00 | Illinois | 0.10 | illinois | #FEE08B |
| 26.00 | California | 0.09 | california | #FEE08B |
| 27.00 | North Dakota | 0.06 | north dakota | #FEE08B |
| 28.00 | South Dakota | -0.01 | south dakota | #FEE08B |
| 29.00 | Ohio | -0.09 | ohio | #FEE08B |
| 30.00 | Idaho | -0.11 | idaho | #FEE08B |
| 31.00 | Florida | -0.12 | florida | #FEE08B |
| 32.00 | Kansas | -0.15 | kansas | #FDAE61 |
| 33.00 | Michigan | -0.15 | michigan | #FDAE61 |
| 34.00 | Alaska | -0.15 | alaska | #FDAE61 |
| 35.00 | Nevada | -0.19 | nevada | #FDAE61 |
| 36.00 | Missouri | -0.20 | missouri | #FDAE61 |
| 37.00 | Indiana | -0.21 | indiana | #FDAE61 |
| 38.00 | North Carolina | -0.21 | north carolina | #FDAE61 |
| 39.00 | West Virginia | -0.29 | west virginia | #FDAE61 |
| 40.00 | New Mexico | -0.33 | new mexico | #FDAE61 |
| 41.00 | Tennessee | -0.37 | tennessee | #F46D43 |
| 42.00 | South Carolina | -0.39 | south carolina | #F46D43 |
| 43.00 | Georgia | -0.42 | georgia | #F46D43 |
| 44.00 | Oklahoma | -0.47 | oklahoma | #F46D43 |
| 45.00 | Arizona | -0.49 | arizona | #F46D43 |
| 46.00 | Alabama | -0.54 | alabama | #F46D43 |
| 47.00 | Kentucky | -0.60 | kentucky | #D73027 |
| 48.00 | Arkansas | -0.77 | arkansas | #D73027 |
| 49.00 | Texas | -0.78 | texas | #D73027 |
| 50.00 | Louisiana | -0.80 | louisiana | #D73027 |
| 51.00 | Mississippi | -1.04 | mississippi | #A50026 |
The data file also includes all the components that went into generating these scores. I won't map all of them, but here's one representative: The HIV infection rate (per 100,000 people).
aids.rates <- read.xlsx(fn, 3, rowIndex = 13:64, colIndex = 1:2, header = F)
colnames(aids.rates) <- c("stateName", "per.100000")
aids.rates.avg <- aids.rates[1, 2]
aids.rates.sd <- sd(aids.rates[-1, 2])
aids.rates$state <- tolower(aids.rates$stateName)
# Standard score. Not using this right now.
aids.rates$Z <- (aids.rates[, 2] - aids.rates.avg)/aids.rates.sd
# DC is an extreme (and disturbing) outlier. Skip it for now.
aids.rates.max <- sort(aids.rates$per.100000)[51]
num.colors <- length(aidsPalette) - 2
aids.color.indices <- as.integer(1 + (aids.rates$per.100000/aids.rates.max *
(num.colors - 1)))
# aids.color.indices[aids.color.indices > num.colors] <- num.colors
aids.rates$color <- aidsPalette[aids.color.indices]
aids.rates$color[is.na(aids.rates$color)] <- darkRed
stately.aids.rates <- join(stately, aids.rates)
aids.map <- statelify(stately.aids.rates)
cat(aids.map)
And again, the data:
| rank | stateName | score | state | color |
|---|---|---|---|---|
| 1.00 | Vermont | 1.24 | vermont | #006837 |
| 2.00 | Connecticut | 0.99 | connecticut | #66BD63 |
| 3.00 | New Hampshire | 0.96 | new hampshire | #66BD63 |
| 4.00 | New Jersey | 0.90 | new jersey | #66BD63 |
| 5.00 | Massachusetts | 0.88 | massachusetts | #66BD63 |
| 6.00 | Maine | 0.79 | maine | #66BD63 |
| 7.00 | Iowa | 0.73 | iowa | #A6D96A |
| 8.00 | Minnesota | 0.73 | minnesota | #A6D96A |
| 9.00 | Hawaii | 0.67 | hawaii | #A6D96A |
| 10.00 | Wisconsin | 0.65 | wisconsin | #A6D96A |
| 11.00 | Oregon | 0.65 | oregon | #A6D96A |
| 12.00 | Washington | 0.64 | washington | #A6D96A |
| 13.00 | Maryland | 0.58 | maryland | #A6D96A |
| 14.00 | New York | 0.47 | new york | #D9EF8B |
| 15.00 | Colorado | 0.37 | colorado | #D9EF8B |
| 16.00 | Delaware | 0.34 | delaware | #D9EF8B |
| 17.00 | Wyoming | 0.30 | wyoming | #FFFFBF |
| 18.00 | Montana | 0.30 | montana | #FFFFBF |
| 19.00 | Rhode Island | 0.27 | rhode island | #FFFFBF |
| 20.00 | District of Columbia | 0.23 | district of columbia | #FFFFBF |
| 21.00 | Nebraska | 0.16 | nebraska | #FFFFBF |
| 22.00 | Pennsylvania | 0.15 | pennsylvania | #FFFFBF |
| 23.00 | Utah | 0.15 | utah | #FFFFBF |
| 24.00 | Virginia | 0.13 | virginia | #FFFFBF |
| 25.00 | Illinois | 0.10 | illinois | #FEE08B |
| 26.00 | California | 0.09 | california | #FEE08B |
| 27.00 | North Dakota | 0.06 | north dakota | #FEE08B |
| 28.00 | South Dakota | -0.01 | south dakota | #FEE08B |
| 29.00 | Ohio | -0.09 | ohio | #FEE08B |
| 30.00 | Idaho | -0.11 | idaho | #FEE08B |
| 31.00 | Florida | -0.12 | florida | #FEE08B |
| 32.00 | Kansas | -0.15 | kansas | #FDAE61 |
| 33.00 | Michigan | -0.15 | michigan | #FDAE61 |
| 34.00 | Alaska | -0.15 | alaska | #FDAE61 |
| 35.00 | Nevada | -0.19 | nevada | #FDAE61 |
| 36.00 | Missouri | -0.20 | missouri | #FDAE61 |
| 37.00 | Indiana | -0.21 | indiana | #FDAE61 |
| 38.00 | North Carolina | -0.21 | north carolina | #FDAE61 |
| 39.00 | West Virginia | -0.29 | west virginia | #FDAE61 |
| 40.00 | New Mexico | -0.33 | new mexico | #FDAE61 |
| 41.00 | Tennessee | -0.37 | tennessee | #F46D43 |
| 42.00 | South Carolina | -0.39 | south carolina | #F46D43 |
| 43.00 | Georgia | -0.42 | georgia | #F46D43 |
| 44.00 | Oklahoma | -0.47 | oklahoma | #F46D43 |
| 45.00 | Arizona | -0.49 | arizona | #F46D43 |
| 46.00 | Alabama | -0.54 | alabama | #F46D43 |
| 47.00 | Kentucky | -0.60 | kentucky | #D73027 |
| 48.00 | Arkansas | -0.77 | arkansas | #D73027 |
| 49.00 | Texas | -0.78 | texas | #D73027 |
| 50.00 | Louisiana | -0.80 | louisiana | #D73027 |
| 51.00 | Mississippi | -1.04 | mississippi | #A50026 |
Posted at 05:42 PM in RStats | Permalink | Comments (0) | TrackBack (0)
News flash! Neurotics are conscientious team members and should be appreciated and used more effectively in organizations. Or so say Corinne Bendersky, an associate professor at UCLA’s Anderson School of Management and Neha Parikh Shah, an assistant professor at Rutgers Business School, in The Downfall of Extraverts and the Rise of Neurotics: The Dynamic Process of Status Allocation in Task Groups.
A recent study from University of Cambridge in England found Rhode Island to be the second-most neurotic state, and the sixth-most disagreeable.—WBRU
Posted at 04:01 PM in New England | Permalink | Comments (0) | TrackBack (0)
I adapted some of the code from my Shiny unemployment app to make a video:
Posted at 06:13 PM in RStats | Permalink | Comments (0) | TrackBack (0)
Posted at 09:35 PM | Permalink | Comments (0) | TrackBack (0)
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](https://github.com/atbradley/shiny_unemployment), so it should be possible to run it with:
runGitHub('shiny_unemployment', 'atbradley')
Posted at 09:02 PM in RStats, Web/Tech | Permalink | Comments (0) | TrackBack (0)
More than unfunny — he is profoundly irritating. And this is not the intense but ultimately superficial irritation that one experiences from, say, a Gilbert Gottfried, akin to a pebble in the shoe or a shard of dust in the eye. Sandlerian irritation is something fundamental, existential; no pebble in one’s shoe but rather a lifetime spent in a cheap motel in a small grey rainy industrial city in the Murmansk Oblast, with a flickering defective neon sign outside one’s window, nothing but Fox News on the TV, the vodka supply depleted, and billions and billions of years to go before the universe finally enters heat death.
—Mrs Tilton, commenting on Lawyers, Guns & Money.
Posted at 06:35 PM in Current Affairs, Television | Permalink | Comments (0) | TrackBack (0)
Matt Asher, over on his blog, analyses the playlist from a local pop-music station in Toronto, and provides an interesting script for generating HTML-based charts in R. He wonders how Radio Paradise's playlist would look in comparison.
I copy-pasted five days worth of Radio Paradise's playlist into this file and tinkered with it in R.
library(devtools)
source_gist(5034250)
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:
cat(HTML.chart(smry, 250, ytLinks = T))
Charting the artists played rather than the tracks gives us a more interesting chart, and reveals that someone at Radio Paradise really likes the Beatles and U2:
cat(HTML.chart(smry.artists, 250))
| The Beatles | ||
| U2 | ||
| Radiohead | ||
| The Shins | ||
| Dire Straits | ||
| Peter Gabriel | ||
| Calexico | ||
| Porcupine Tree | ||
| R.E.M. | ||
| Rolling Stones | ||
| Beck | ||
| The Cure | ||
| Elbow | ||
| Elvis Costello | ||
| The Black Keys | ||
| Tom Petty | ||
| Wilco | ||
| Cowboy Junkies | ||
| Los Lobos | ||
| Morcheeba | ||
| Talking Heads | ||
| Beth Orton | ||
| Bob Dylan | ||
| Bob Marley | ||
| Fleetwood Mac | ||
| Neko Case | ||
| Norah Jones | ||
| Pearl Jam | ||
| Supergrass | ||
| The Dandy Warhols | ||
| The Decemberists | ||
| Thievery Corporation | ||
| Aimee Mann | ||
| Andrew Bird | ||
| Anna Ternheim | ||
| Arcade Fire | ||
| Chris Isaak | ||
| David Bowie | ||
| Death Cab for Cutie | ||
| Doves | ||
| Eels | ||
| Fleet Foxes | ||
| John Lee Hooker | ||
| Led Zeppelin | ||
| Nick Drake | ||
| Night Beds | ||
| Patty Griffin | ||
| Pink Floyd | ||
| Radical Face | ||
| The Derek Trucks Band | ||
| Tori Amos | ||
| Air | ||
| Alt-J | ||
| Band of Horses | ||
| Ben Harper | ||
| Big Sugar | ||
| Built To Spill | ||
| Cake | ||
| Crowded House | ||
| Elliott Smith | ||
| Gomez | ||
| Great Lake Swimmers | ||
| Iron & Wine | ||
| Jack White | ||
| Neil Halstead | ||
| PJ Harvey | ||
| Stevie Wonder | ||
| The Doors | ||
| The Kinks | ||
| The Who | ||
| Black Rebel Motorcycle Club | ||
| Bonobo | ||
| Bruce Cockburn | ||
| Cult With No Name | ||
| Dave Matthews Band | ||
| Death Cab For Cutie | ||
| Dengue Fever | ||
| Depeche Mode | ||
| Elephant Revival | ||
| Fink | ||
| Grateful Dead | ||
| Harry Manx | ||
| Jeff Beck | ||
| John Lennon | ||
| Joni Mitchell | ||
| José González | ||
| Loreena McKennitt | ||
| Lucinda Williams | ||
| Ludovico Einaudi | ||
| Mark Knopfler | ||
| Morphine | ||
| Muddy Waters | ||
| Neil Young | ||
| Oi Va Voi | ||
| Other Lives | ||
| Paul Simon | ||
| Ray LaMontagne | ||
| Rilo Kiley | ||
| Santana | ||
| Silversun Pickups | ||
| Son Volt | ||
| Spoon | ||
| Stereophonics | ||
| Stone Roses | ||
| Suzanne Vega | ||
| The Police | ||
| The Pretenders | ||
| Tom Waits | ||
| Vast | ||
| Wye Oak | ||
| Younger Brother | ||
| Afro Celt Sound System | ||
| Amy Winehouse | ||
| Antje Duvekot | ||
| Bat For Lashes | ||
| Boy & Bear | ||
| Broken Bells | ||
| Broken Social Scene | ||
| Caro Emerald | ||
| Cracker | ||
| Cult with No Name | ||
| Danger Mouse & Daniele Luppi | ||
| Doc Watson | ||
| Duke Ellington | ||
| Eric Clapton | ||
| First Aid Kit | ||
| Gillian Welch | ||
| Githead | ||
| Gotye | ||
| Gregory Alan Isakov | ||
| Gustavo Santaolalla | ||
| Guster | ||
| Hooverphonic | ||
| Jefferson Airplane | ||
| Jenn Grant | ||
| Jenny Lewis | ||
| Jimi Hendrix | ||
| Jimmy Cliff | ||
| Joe Strummer & The Mescaleros | ||
| Johnny Marr | ||
| José González | ||
| Junip | ||
| KT Tunstall | ||
| Kate Miller-Heidke | ||
| Kathleen Edwards | ||
| Keren Ann | ||
| Laura Marling | ||
| Leo Kottke | ||
| Lost In The Trees | ||
| Luna | ||
| Madrugada | ||
| Massive Attack | ||
| Medeski, Martin & Wood | ||
| My Morning Jacket | ||
| Old 97s | ||
| Paul Weller | ||
| Poe | ||
| Rebecca Zapen | ||
| Robert Plant | ||
| Sarah Blasko | ||
| Sarah McLachlan | ||
| Soha | ||
| Sophie Zelmani | ||
| Tame Impala | ||
| The Barr Brothers | ||
| The Byrds | ||
| The Cinematic Orchestra | ||
| The Jam | ||
| The National | ||
| The Republic Tigers | ||
| The Slow Show | ||
| The Smashing Pumpkins | ||
| The Wailin' Jennys | ||
| The Wallflowers | ||
| Thea Gilmore | ||
| Toad The Wet Sprocket | ||
| Toots & The Maytals | ||
| Van Morrison | ||
| Vienna Teng | ||
| Ween | ||
| thenewno2 | ||
| 1 Giant Leap | ||
| A Fine Frenzy | ||
| Alpha Rev | ||
| Amadou & Mariam | ||
| Amy Macdonald | ||
| Ane Brun | ||
| Anni B Sweet | ||
| Aretha Franklin | ||
| Barra and Govinda | ||
| Basia Bulat | ||
| Big Country | ||
| Big Head Todd & The Monsters | ||
| Billie Holiday | ||
| Björk | ||
| Blackfield | ||
| Blood Sweat & Tears | ||
| Bohren & Der Club Of Gore | ||
| Buffalo Springfield | ||
| Cat Power | ||
| Chinawoman | ||
| Choir of Young Believers | ||
| Chris Whitley | ||
| Christians and Lions | ||
| Claude Chalhoub | ||
| Cloud Cult | ||
| Coldplay | ||
| Creedence Clearwater Revival | ||
| Crosby Stills & Nash | ||
| Dandy Livingstone | ||
| David Byrne & St. Vincent | ||
| David Gilmour | ||
| Derek and the Dominoes | ||
| Donovan | ||
| Eastmountainsouth | ||
| Elliott Brood | ||
| Elton John | ||
| Emily Barker & the Red Clay Halo | ||
| Entrain | ||
| Equation | ||
| Feist | ||
| Fiona Apple | ||
| Flaming Lips | ||
| Garbage | ||
| George Harrison | ||
| Glen Hansard | ||
| Gooding | ||
| Greg Laswell | ||
| Grinderman | ||
| Grizzly Bear | ||
| Gus Black | ||
| Hem | ||
| I Am Kloot | ||
| Ian Moore | ||
| Imogen Heap | ||
| Interpol | ||
| Ismael Lo | ||
| J.J. Cale | ||
| Jackson Browne | ||
| James Taylor | ||
| Jenny Lewis & The Watson Twins | ||
| Jesse Sykes & The Sweet Hereafter | ||
| Joan Osborne | ||
| Joe Bonamassa | ||
| John Cale & Brian Eno | ||
| John Hiatt | ||
| John Martyn | ||
| John Mellencamp | ||
| Kate Bush | ||
| Little Feat | ||
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).
Posted at 08:25 PM | Permalink | Comments (0) | TrackBack (0)