[R] Pie charts using plotGooglemaps

Jim Lemon jim at bitwrit.com.au
Wed Apr 16 11:51:43 CEST 2014


On 04/16/2014 04:43 AM, DrunkenPhD wrote:
> Sorry Jim not for my beginner level :(((
>
> So if my data are like this :
>
> xyCityVillage
>
> 19.943731440.7086377120425
>
> 20.221417141.492433611
>
> 20.095589139.948136444
>
> 20.950663640.64473471015
>
> how do I plot for every point(x,y) a pie chart with slices(City,Village)?
>
> Regards
>
>
> how do I plot for every point(x,y) a pie chart with slices(City,Village)?
>
>
Okay, let's try again.

# get yer data
sampledf<-read.table(text="x y City Village
  19.9437314 40.7086377 120 425
  20.2214171 41.4924336 1 1
  20.0955891 39.9481364 4 4
  20.9506636 40.6447347 10 15",header=TRUE)
# make the graphics device high enough to hold Albania
x11(height=10,width=5)
# display the map upon which you want the pies
map(xlim=c(19,21.1),ylim=c(39.5,42.6))
# display the pies
library(plotrix)
for(pp in 1:4) floating.pie(sampledf[pp,"x"],sampledf[pp,"y"],
  unlist(sampledf[pp,c("City","Village")]),radius=0.1)

Jim




More information about the R-help mailing list