Graphics Programs Reference
In-Depth Information
CrEATE STAr ChArTS
Now use the same crime data used for Figure 7-13 to see if it makes any
difference to use these star charts. First things first. Load the data into R.
crime <- read.csv(“http://datasets.flowingdata.com/
crimeRatesByState-formatted.csv”)
Now it's as straightforward to make star charts as it was to make Chernoff
Faces. Use the stars() function, which comes packaged with base R.
stars(crime)
The default charts are shown in Figure 7-15. Hopefully, these won't offend
anyone. Of course, you still need state labels, but you also need a key to
tell you which dimension is which. A certain order is followed, like with
faces() , but you don't know where the first variable starts. So take care
of both in one swoop. Notice that you can change to first column to row
names just like you did with the heatmap. You can also set flip.labels to
FALSE , because you don't want the labels to alternate heights. Figure 7-16
shows the results.
row.names(crime) <- crime$state
crime <- crime[,2:7]
stars(crime, flip.labels=FALSE, key.loc = c(15, 1.5))
It's relatively easy to spot the differences and similarities now. In the Cher-
noff version, the District of Columbia looked like a wild-eyed clown com-
pared to all the other states, but with the star version, you see that yes, it
does have high rates of crime in some categories, but relatively lower rates
of forcible rape and burglary. It's also easy to find the states with relatively
low crime rates such as New Hampshire and Rhode Island. Then there are
states such as North Carolina that are high in just a single category.
For this dataset, I'm satisfied with this format, but there are two variations
that you might want to try with your own data. The first restricts all data to
the top half of the circle, as shown in Figure 7-17.
stars(crime, flip.labels=FALSE, key.loc = c(15, 1.5), full=FALSE)
The second variation uses the length of the segments instead of placement
of points, as shown in Figure 7-18. These are actually Nightingale charts
(also known as polar area diagrams) more than they are star charts, but
there you go. If you do go with this option, you might want to try a different
color scheme other than this crazy default one.
stars(crime, flip.labels=FALSE, key.loc = c(15, 1.5), draw.segments=TRUE)
Search WWH ::




Custom Search