I spent a lot of time reading about and playing around with the code, as well as how the code behaved with different data sets. The data set I decided to use for the submission of this assignment is USPop, which is a record of data that reflects the population of the United States from 1790 to 2000. Following is a visualization example that I created for basic, lattice and ggplot2 packages.
Base Graphics
Base graphics consists of the most basic options that are available in the R programming language. I experimented a lot with plot(), and came up with this:
plot(USPop, col="green", type"b", cex=1.5, pch=4)
Apologies for the small size of the image, but making it any larger would have conflicted with blogger's format. You can click the image and save it so that you can view it larger, if you like! I made the following modifications:
- Changed color from black to green.
- Set point character to X.
- Increased plot point size 1.5 times.
- Set plot style to points connected by line segments (b).
Lattice Package
The Lattice package is useful because it creates the entire plot at once. It's also able to display many plot points and handle those easier than base would. Lattice also falls short in some areas. It can be difficult to manipulate, and you cannot make changes to a lattice plot after it has been created. Lattice did not suit my data set very well, I believe because I only had two points. As such, I chose the xyplot:
xyplot(population~year, data=USPop, pch="*", cex=3)
I personally found this difficult to use, moreso than base, because I don't think my data set was really complex enough to leverage the benefits of lattice.
GGPlot2 Package
GGPlot2 is more like a design app than either of the other graphical methods available in R. GGPlot2 is excellent, and provides more variety in terms of changes the user can make, than either of the other packages as well. Following is an example I created using my data set:
ggplot(USPop, aes(year, population))
In my opinion, GGPlot2 is the best package to use because it provides the most options to work with different visualizations, etc. and is far and away the most powerful tool in this respect. I would have liked to work longer on this particular portion but I'm afraid I've run out of time! I look forward to utilizing GGPlot2 in future assignments and projects.
No comments:
Post a Comment