Graphics Programs Reference
In-Depth Information
FIGurE 6-15 Bubble plot showing crime in the United States
To start, load the data in R with read.csv() . This is the same data that you
just used, except a column for population was added, and Washington, DC
is not included. It's also tab-delimited instead of comma-delimited. No
biggie. Simply change the sep argument in the function.
crime <-
read.csv(“http://datasets.flowingdata.com/crimeRatesByState2005.tsv”,
header=TRUE, sep=”\t”)
Then jump right into drawing some bubbles with the symbols() func-
tion. The x-axis is murder rate, the y-axis is burglary rate, and radius of
bubbles is sized proportionally to population. Figure 6-16 shows the result.
Want to do try more with symbols() ? You'll get to that soon.
symbols(crime$murder, crime$burglary, circles=crime$population)
Search WWH ::




Custom Search