Load the gapminder data from gapminderDataFiveYear.txt into memory
gDat <- read.delim("gapminderDataFiveYear.txt")
Number of observations:
nrow(gDat)
## [1] 1704
Variables:
names(gDat)
## [1] "country" "year" "pop" "continent" "lifeExp" "gdpPercap"
Some statistical summary of the data set:
summary(gDat)
## country year pop continent
## Afghanistan: 12 Min. :1952 Min. :6.001e+04 Africa :624
## Albania : 12 1st Qu.:1966 1st Qu.:2.794e+06 Americas:300
## Algeria : 12 Median :1980 Median :7.024e+06 Asia :396
## Angola : 12 Mean :1980 Mean :2.960e+07 Europe :360
## Argentina : 12 3rd Qu.:1993 3rd Qu.:1.959e+07 Oceania : 24
## Australia : 12 Max. :2007 Max. :1.319e+09
## (Other) :1632
## lifeExp gdpPercap
## Min. :23.60 Min. : 241.2
## 1st Qu.:48.20 1st Qu.: 1202.1
## Median :60.71 Median : 3531.8
## Mean :59.47 Mean : 7215.3
## 3rd Qu.:70.85 3rd Qu.: 9325.5
## Max. :82.60 Max. :113523.1
##
Plot the corelation between lifeExp and gdpPercap in China after 1980
library(lattice)
## Warning: package 'lattice' was built under R version 3.0.2
xyplot(lifeExp ~ gdpPercap, data = gDat,subset = (country == "China" & year >=1980))