Data used for this is found here
Start by loading data and required libraries:
library("lattice")
gDat <- read.delim("gapminderDataFiveYear.txt")
Printing some basic infomation:
colnames(gDat)
## [1] "country" "year" "pop" "continent" "lifeExp" "gdpPercap"
summary(gDat["year"])
## year
## Min. :1952
## 1st Qu.:1966
## Median :1980
## Mean :1980
## 3rd Qu.:1993
## Max. :2007
length(unique(gDat$country))
## [1] 142
Now for actually showing/plotting something
Though it may be a bit morbid, I thought it would be interesting to how much of an affect a genocide taking place in a country might have in the overall lifespan and population statistics.
I used wikipedia to pick countries to plot
xyplot(pop ~ year | country, gDat, subset = (country == "Cambodia"), type = c("p",
"spline"))
xyplot(lifeExp ~ year | country, gDat, subset = (country == "Cambodia"), type = c("p",
"spline"))
xyplot(pop ~ year | country, gDat, subset = (country == "Rwanda"), type = c("p",
"spline"))
xyplot(lifeExp ~ year | country, gDat, subset = (country == "Rwanda"), type = c("p",
"spline"))
I think I'll stop now since I'm getting depressed now and I kind of regret plotting this. Anyways the point of the assignment was to show we can write a markdown document and I hope this was adequate in showing that.