**The Pretty Graph Blog » R**, and kindly contributed to R-bloggers)

Nathan at Flowingata put up another interesting challenge today to improve the following graphic showing obesity trends in America.

Here’s my attempt:

I transposed the data so that the cohorts are on the X axis and each separate line represents an age group. So each line shows the percentage of obese people in a particular age group. This way the graph tells you the probability of you being obese at a given age in a particular decade.

For each age group, the line roughly trends upwards. For example, the lavender (violet? 3rd from bottom) line shows that if you were in your twenties during the World War II chances of you being obese were just below 10%, but if you were in your twenties during the mid 60s-70s (rocking out to The Doors?) you were more than twice as likely to be obese.

So, from a cursory look, it does seem that Americans have been getting obese faster.

For those interested, here’s my modified data file and the R code:

o<-read.csv(“obesity_edit.csv”)

colnames(o)<-c(“Age group”,”2-9 Y”,”10-19 Y”,”20-29 Y”,”30-39 Y”,”40-49 Y”,”50-59 Y”,”60-69 Y”,”70-79 Y”)

library(RColorBrewer)

pal<-brewer.pal(length(colnames(o)),”Set1″)

plot(o[,2],pch=19,xaxt=”n”,col=pal[2],type=”o”,ylim=c(0,max(o[,-1],na.rm=T)),xlab=”Cohort by Decade”,ylab=”Percentage of Obese People”,main=”Obesity trends by Age Group”)

for(i in 3:length(colnames(o))) {

points(o[,i],pch=19,xaxt=”n”,col=pal[i])

lines(o[,i],pch=19,xaxt=”n”,col=pal[i])

}

axis(1,at=1:length(o[,1]),labels=o[,1],cex.axis=0.75)

legend(“topright”,legend=colnames(o)[-1],col=pal[-1],lty=1,pch=19,bty=”n”)

**leave a comment**for the author, please follow the link and comment on his blog:

**The Pretty Graph Blog » 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...