Question

After struggling with some maps I came to the point where I don't know any further. I want to add pie charts to a geographical map.

Here is my data:

    zip city      state  latitude   longitude   plan_chosen
  10001 New York    NY  40.75074    -73.99653   3
  10001 New York    NY  40.75074    -73.99653   1
  10001 New York    NY  40.75074    -73.99653   1
  10017 New York    NY  40.75216    -73.97231   3

This is also for other locations.What I want to do is define a pie chart of plan_chosen. This consists of numbers 1 to 4, and I want to put this pie chart on the map of the states of course in the NY area and some other selected areas. I couldn't really find a tutorial on how to do this and I don't know which package to use best. Just for mapping I've been using the package maps

I use this code to define the map

map('state', fill=FALSE, col="#cccccc")

on this I want to add 3 to 4 pie charts. Do I have to modify the data any further or which package is useful?

I've been trying the package rworldmap and this code

mapPies( tel,nameX="longitude", nameY="latitude" , nameZs=plan_chosen,mapRegion='america' , add=TRUE)

but here my problem is it doesn't divide the pie in 4 parts it just colors it all black. Any suggestions or help?

Was it helpful?

Solution

There is a function in the plotrix package that will create floating pie charts. But note that the author of the function does not encourage their use, he wrote it to show that R can descend to making plots that are as useless as excel in hopes that users would then be converted to better ways of presenting their data.

You can also use the subplot function in the TeachingDemos package to add any type of chart to an existing plot (map), so it could be used with pie charts, or other more useful charts. Also look at the my.symbols function in the same package for other ways to add information to an existing plot/map.

Others have mentioned Edward Tufte (excelent suggestions), but also look for William Cleveland for studies on the effectiveness (or lack there of) of different types of plots.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top