Question

I have a data frame like

 X                date         lon      lat 
1 1 2014-01-08 23:50:13 -116.576504 53.93327
2 2 2014-01-08 23:35:50          NA       NA
3 3 2014-01-08 23:06:33          NA       NA
4 4 2014-01-08 23:06:07  -76.670200 39.38100
5 5 2014-01-08 22:44:37  -77.436048 37.54072
6 6 2014-01-08 22:35:56    7.189811 43.67342

and I would like to map it on a world shape file, but if my points could be in hexagon... with ggplot2 .. it will be great! I'm not abble to use geom_hex ... it doesn't make what I whant ... Something like that but with a world map below. A complexe way is on the slide 22 of this presentation , I have tried

wp<-ggplot()+
  geom_polygon(data=word.df,aes(long,lat,group=group))+
  geom_path(color="white")+
  geom_hex(data=cleanTwittes,aes(lon,lat))+
  coord_equal()

but I'have this error : 'Erreur dans if (nrow(layer_data) == 0) return() : '

thank's

Was it helpful?

Solution

I have find something :-)

wp<-ggplot()+
   geom_polygon(data=word.df,aes(long,lat,group=group))+
   geom_hex(data=cleanTwittes,aes(lon,lat),bins = 55,alpha=8/10)+
   theme_bw()+
   labs(title = paste(nbTwittes,"twittes entre",minT,"et",maxT, "sur 'terroir'"))
   coord_equal()

It make a map not so bad enter image description here

But if you have some sugestion ...

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