Dependencies

This document depends on the following packages:

  library(devtools)
  library(Biobase)

To install these packages you can use the code (or if you are compiling the document, remove the eval=FALSE from the chunk.)

install.packages(c("devtools"))
source("http://www.bioconductor.org/biocLite.R")
biocLite(c("Biobase"))

WHO childhood hunger data

hunger = read.csv("http://apps.who.int/gho/athena/data/GHO/WHOSIS_000008.csv?profile=text&filter=COUNTRY:*;SEX:*")
hunger <- hunger[hunger$Sex!="Both sexes",]
head(hunger)
##                                 Indicator Data.Source PUBLISH.STATES Year
## 4  Children aged <5 years underweight (%) NLIS_312819      Published 2004
## 5  Children aged <5 years underweight (%) NLIS_311928      Published 1998
## 8  Children aged <5 years underweight (%) NLIS_312965      Published 2005
## 9  Children aged <5 years underweight (%) NLIS_312244      Published 2000
## 12 Children aged <5 years underweight (%) NLIS_312852      Published 2006
## 15 Children aged <5 years underweight (%) NLIS_313106      Published 2004
##               WHO.region      Country    Sex Display.Value Numeric Low
## 4  Eastern Mediterranean  Afghanistan Female          33.0    33.0  NA
## 5                 Africa     Cameroon   Male          20.1    20.1  NA
## 8                 Africa      Algeria   Male           3.7     3.7  NA
## 9                 Europe   Azerbaijan   Male          13.2    13.2  NA
## 12 Eastern Mediterranean      Somalia Female          31.3    31.3  NA
## 15                Africa South Africa   Male          13.6    13.6  NA
##    High Comments
## 4    NA       NA
## 5    NA       NA
## 8    NA       NA
## 9    NA       NA
## 12   NA       NA
## 15   NA       NA

Plot percent hungry versus time

lm1 <- lm(hunger$Numeric ~ hunger$Year)
plot(hunger$Year,hunger$Numeric,pch=19,col="blue")

Add the linear model

lm1 <- lm(hunger$Numeric ~ hunger$Year)
plot(hunger$Year,hunger$Numeric,pch=19,col="blue")
lines(hunger$Year,lm1$fitted,lwd=3,col="darkgrey")

Color by male/female

plot(hunger$Year,hunger$Numeric,pch=19)
points(hunger$Year,hunger$Numeric,pch=19,col=((hunger$Sex=="Male")*1+1))

Color by male/female

lmM <- lm(hunger$Numeric[hunger$Sex=="Male"] ~ hunger$Year[hunger$Sex=="Male"])
lmF <- lm(hunger$Numeric[hunger$Sex=="Female"] ~ hunger$Year[hunger$Sex=="Female"])
plot(hunger$Year,hunger$Numeric,pch=19)
points(hunger$Year,hunger$Numeric,pch=19,col=((hunger$Sex=="Male")*1+1))
lines(hunger$Year[hunger$Sex=="Male"],lmM$fitted,col="black",lwd=3)
lines(hunger$Year[hunger$Sex=="Female"],lmF$fitted,col="red",lwd=3)