Sunday, May 19, 2013

Keep R Rockin' Me Baby

I've been to Phoenix, AZ. I know I've been to Seattle, but I'm not sure if I made it to Tacoma. I once rode the train from DC to NY, which had at least one stop in Philadelphia. I've somehow never been to Atlanta, not even for a layover; I've been to L.A., and I've seen Northern California.

In the song "Rockin' Me" Steve Miller travels to all these destinations. He does so, he first claims, to be with his “sweet baby,” only a few verses later "just to hear [his] sweet baby say 'Keep on a rockin' me baby.'" The thing I don’t really understand, however, is why he needs to visit these locations.

One thought, based on the first verse, is that he is travelling to all of these cities looking real hard to find a job. Another theory is he has found a job which requires his travel. Perhaps he’s just stalking this girl, but I kind of always thought he was just on a concert tour.

Regardless of the reason, I’ve found the list of cities to be curious. We start out in Phoenix, a southwestern US city, and the only city listed in which the state is named. He might name the state to ensure that we don't get it confused with one of the other 6 cities/towns named Phoenix, but I think that it’s probably because Arizona is a near-rhyme with the next city: Tacoma. From the southwest to the northwest, we round off the four corners of the country with Philadelphia and Atlanta, only to end up back on the west coast in L.A. From there it’s just a short trip up the coast to Northern California (38.2813° N, 120.9045° W), where the Steve Miller Band happened to call home. I really don’t know if I am just reading too much into the lyrics, but that is a long trip! How long? Well, I thought I’d approximate it:


So that’s really it - I wanted to know how far this alleged trip was, and if past the convenient rhymes and less convenient proximities, if there were any patterns that emerged from plotting out this odyssey.

The answer - no.



R Code:


library(maps)
library(animation)
cities = c("Phoenix, AZ","Tacoma","Philadelphia","Atlanta","L.A.","Northern California")
lat = c(33.4492,47.2531,39.9522,33.7489,34.0522,38.2813)
long = -c(112.0739,122.4431,75.1642,84.3881,118.2428,120.9045)
distance = c(1093,2381,658,1938,336)

m=map("state", interior = T)
par(mar=c(0,0,0,0))
par(mar=c(5,4,4,2)+.1)
y.seq = x.seq=NULL
slope = rep(NA,length(lat)-1)
int = rep(NA,length(lat)-1)
d=NULL
for(i in 2:length(lat)-1) {
  slope[i] = (lat[i+1]-lat[i])/(long[i+1]-long[i])
  int[i] = lat[i]-slope[i]*long[i]

  l.out = sqrt((long[i]-long[i+1])^2 + (lat[i]-lat[i+1])^2)

  x.seq[[i]] = seq(long[i],long[i+1],length.out=l.out)
  y.seq[[i]] = int[i] + x.seq[[i]]*slope[i]

  a1 = lat[i]
  a2 = lat[i+1]
  b1 = long[i]
  b2 = long[i+1]
  d[[i]] = seq(0,distance[i],length=l.out)
}
x.seq[[5]] = c(x.seq[[5]],rep(x.seq[[5]][5],10))
y.seq[[5]] = c(y.seq[[5]],rep(y.seq[[5]][5],10))
d[[5]] = c(d[[5]],rep(d[[5]][5],10))
for(x in 2:5) {
  d[[x]] = d[[x]]+d[[x-1]][length(d[[x-1]])]
}

saveGIF({
  for(i in 1:5) {
    for(j in 1:length(x.seq[[i]])) {
      plot(m,type="l",axes=F,col="steelblue",xlab="",ylab="",
           main="Rockin' Me")
      #map("state", boundary = FALSE, col="gray70", add = TRUE)
   
      points(long[0:i+1],lat[0:i+1],cex=.7,pch=16)
      text(long[0:i+1],lat[0:i+1],cities[0:i+1],pos=c(1,3,3,1,1,3)[0:i+1],cex=1.1,col="red")
      text(-98.5795,39.5285,paste(round(d[[i]][j]),"Miles"),cex=1.3,col="blue2")
      if(i>1) {
        for(q in 1:(i-1)) {
          lines(x.seq[[q]],y.seq[[q]])
        }      
      }
      lines(x.seq[[i]][c(1,j)],y.seq[[i]][c(1,j)])
    }  
  }
}, movie.name = "rockinmebaby.gif", interval = 0.03, nmax = 1000,
        ani.width = 930, ani.height = 600)