Graphics Programs Reference
In-Depth Information
into. Obviously you're going to go the visualization route, or I would have
named this topic Analyze This .
Multiple Distributions
So far you've looked at only single distributions, namely birth rates for
2008. But if you looked at the data file or the data frame in R, you know
that you have annual birth rates all the way back to 1960. If you didn't look,
then um, you still have annual birth rates all the way back to 1960. Like I
said earlier, the world birth rate has decreased significantly, but how has
the entire distribution changed?
Now take the straightforward route to create a histogram for every year
and lay them out nicely organized as a matrix. It's a similar idea to the
scatterplot matrix designed at the beginning of this chapter.
CrEATE A hISToGrAM MATrIx
The lattice package in R makes it easy to create a whole bunch of histo-
grams with just one line of code, but there's a small catch. You have to give
it the data in the format that the function wants it. Following is a snippet of
the originally loaded text file.
Country,1960,1961,1962,1963...
Aruba,36.4,35.179,33.863,32.459...
Afghanistan,52.201,52.206,52.208,52.204...
...
There's a row for each country. The first column is the country name, and
then there's a column for each year, so there are 30 columns and 234 rows
of data, plus the header. You need the data to be in two columns though,
one for the year and the other for the birth rate. You don't actually need
country names for this, so the first few rows should look like this.
year,rate
1960,36.4
1961,35.179
1962,33.863
1963,32.459
1964,30.994
1965,29.513
...
Search WWH ::




Custom Search