(This article was first published on

**OutLie..R**, and kindly contributed to R-bloggers)The second community event is the Soldier Hollow Junior Olympics (SoHo), again found in the Heber Valley area. Building upon the previous posts (part 1 and part 2) this one will show an event that has more people coming from greater distance. Take the bar charts for the number of participants and the cities they are from. Instead of 2 major cities (Heber Valley Railroad), SoHo has several cities and states with many participants for each.

The histogram for distance shows a similar pattern, where with the railroad it was a nice log looking distribution, this is a little more even. The second histogram is a zoomed in and the bins expanded for greater detail.

While the map is not as great as the railroad, which is why the distance histogram is so important, it does show a good representation of the northwestern states. Unlike the railroad map, each line does represent more participants than 3.

`#Soldier Hallow Analysis`

soho<-read.csv(file.choose(), header=TRUE)

summary(soho)

table.city<-sort(table(soho$city), decreasing=TRUE)

table.st<-sort(table(soho$state), decreasing=TRUE)

par(mar=c(5, 11, 4, 2), las=2)

barplot(table.city, main=‘SoHo: Cities’, horiz=TRUE, col=‘red’)

par(mar=c(5, 4, 4, 2), las=2)

barplot(table.st, main=‘SoHo: States’, horiz=TRUE, col=‘red’)

heber<-c(-111.33259, 40.511413)

soho.data<-matrix(data=c(soho$long, soho$lat), nrow=373, ncol=2)

soho.ut<-subset(soho, subset=(state==‘UT’))

soho.data.ut<-matrix(data=c(soho.ut$long, soho.ut$lat), nrow=29, ncol=2)

soho.dist<-(distm(heber, soho.data, fun=distVincentyEllipsoid)*0.000621371192)

soho.dist.ut<-(distm(heber, soho.data.ut, fun=distVincentyEllipsoid)*0.000621371192)

dist.soho<-matrix(soho.dist, nrow=373, ncol=1)

dist.soho.ut<-matrix(soho.dist.ut, nrow=29, ncol=1)

summary(dist.soho)

sd(dist.soho)

p.skew.soho<-(3*(mean(dist.soho)-median(dist.soho)))/sd(dist.soho)

hist(dist.soho, main=‘SoHo: Distance Histogram’, col=‘red’)

hist(dist.soho.ut, main=‘SoHo: Distance Histogram Utah’, breaks=20, col=‘red’)

#mapping it out

#US

map("state", col="#f2f2f2", fill=TRUE, bg="white", lwd=0.25)

title(main=‘SoHo: US Map’)

for(i in 1:dim(soho.data)[1]){

inter <- gcIntermediate(heber, soho.data[i, 1:2], n=373, addStartEnd=TRUE)

lines(inter, col="red")

}

#Zoomed into West

par(mfrow=c(1,2), mar=c(5,4,4,2))

map("state", col="#f2f2f2", fill=TRUE, bg="white", lwd=0.25, xlim=c(-125, -103), ylim=c(30, 50))

title(main=‘SoHo: Western Region’)

for(i in 1:dim(soho.data)[1]){

inter <- gcIntermediate(heber, soho.data[i, 1:2], n=373, addStartEnd=TRUE)

lines(inter, col="red")

}

#Utah

map("state", col="#f2f2f2", fill=TRUE, bg="white", lwd=0.25, xlim=c(-112.1, -111), ylim=c(40, 42))

title(main=‘SoHo: Utah’)

for(i in 1:dim(soho.data.ut)[1]){

inter <- gcIntermediate(heber, soho.data.ut[i, 1:2], n=29, addStartEnd=TRUE)

lines(inter, col="red")

}

par(mfrow=c(1,1))

To

**leave a comment**for the author, please follow the link and comment on his blog:**OutLie..R**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...