Last active
December 22, 2015 23:19
-
-
Save geoffwoollard/6545701 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stat545a-2013-hw02_woollard-geo | |
======================================================== | |
Let's explore the gap minder data. You can find it [here](http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/examples/gapminder/data/gapminderDataFiveYear.txt) | |
```{r} | |
library(lattice) | |
gdURL <- "http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/examples/gapminder/data/gapminderDataFiveYear.txt" | |
gDat <- read.table(gdURL, header = TRUE, sep = '\t', quote = "\"") | |
``` | |
What is in gDat? | |
```{r} | |
str(gDat) | |
``` | |
Some elementary statistics | |
```{r} | |
summary(gDat) | |
``` | |
The year range | |
```{r} | |
min(gDat$year) | |
max(gDat$year) | |
``` | |
Does the data seem reasonable? | |
* China is Big | |
* Japan is Healthy | |
```{r} | |
gDat[which(gDat$pop == max(gDat$pop)),] | |
gDat[which(gDat$pop == max(gDat$pop)),]$pop | |
gDat[which(gDat$lifeExp == max(gDat$lifeExp)),] | |
gDat[which(gDat$lifeExp == max(gDat$lifeExp)),]$lifeExp | |
``` | |
Let's make some **pictures**. | |
* How has life changed since the post WW2 era? | |
```{r fig.width=7, fig.height=6} | |
xyplot(pop ~ year | continent, gDat) | |
``` | |
Very interesting! Where are all those lovely asians coming from? | |
```{r fig.width=7, fig.height=6} | |
xyplot(pop ~ year | country, subset(within.data.frame(gDat, country <- strtrim(gDat$country,8) ), continent == "Asia")) | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you see something 'very interesting', why not go a little further to explain what/why is so interesting?