PageRenderTime 17ms CodeModel.GetById 15ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 0ms

/murder.R

http://github.com/tavisrudd/r_users_group_1
R | 22 lines | 9 code | 6 blank | 7 comment | 0 complexity | 629e1e7545ae50676499a0d7c9bbb48f MD5 | raw file
 1# http://flowingdata.com/2010/11/23/how-to-make-bubble-charts/
 2
 3crime <- read.csv("http://datasets.flowingdata.com/crimeRatesByState2008.csv",
 4                  header=TRUE, sep="\t")
 5
 6## initial attempt
 7symbols(crime$murder, crime$burglary, circles=crime$population)
 8
 9## Add population proportional circle sizing
10radius <- sqrt(crime$population/ pi)
11symbols(crime$murder, crime$burglary, circles=radius)
12
13## Add colours and labels
14symbols(crime$murder, crime$burglary, circles=radius,
15        inches=0.35, fg="white", bg="red",
16        xlab="Murder Rate", ylab="Burglary Rate")
17
18## the following line would graph it with squares instead of circles
19## symbols(crime$murder, crime$burglary, squares=sqrt(crime$population), inches=0.5)
20
21## Add State names
22text(crime$murder, crime$burglary, crime$state, cex=0.5)