sebastianbarfort / mapDK

R package for making maps of Denmark
49 stars 5 forks source link

subset plots by municipality etc #4

Closed sebastianbarfort closed 8 years ago

sebastianbarfort commented 9 years ago

package should be able to subset zip/polling/etc plots by municipality. Suggested by @RobertKlemmensen.

RobertKlemmensen commented 9 years ago

Fantastico!!!

Jeg prøver der med det samme!

KH R

2015-02-23 19:51 GMT+01:00 Sebastian Barfort notifications@github.com:

package should be able to subset zip/polling/etc plots by municipality. Suggested by @RobertKlemmensen https://github.com/RobertKlemmensen.

— Reply to this email directly or view it on GitHub https://github.com/sebastianbarfort/mapDK/issues/4.

Robert Klemmensen Professor (mso) Department of Political Science University of Southern Denmark Cell (+45) 4022 7614 Office (+45) 6550 2194

sebastianbarfort commented 9 years ago

It won't be difficult.

Try and run the newest developer version:

library(devtools)
install_github("sebastianbarfort/mapDK")

I've added a sub.plot option that you can specify by municipality.

# plot only copenhagen
mapDK(values = "stemmer", id = "id", 
data = subset(votes, navn == "socialdemokratiet"),
detail = "polling", show.missing = FALSE,
guide.label = "Stemmer \nSocialdemokratiet (pct)",
sub.plot = "koebenhavn")

Will produce this

It currently only works for detail = polling, but I'll implement for zip & co as soon as possible.

Note to self: might be better to facet when plotting more than one municipality.

sebastianbarfort commented 9 years ago

Update: I can't find any information that maps zips into municipalities. I could do this manually, but that's too much for Monday night.

At present, the mapDK function now has a sub.plot function that works only if detail = polling. If you pass it more than one municipality it will return some pretty cool facetted plots.

mapDK(values = "stemmer", id = "id", 
    data = subset(votes, navn == "socialdemokratiet"),
    detail = "polling", show.missing = FALSE,
    guide.label = "Stemmer \nSocialdemokratiet (pct)",
    sub.plot = c("koebenhavn", "aarhus")) 

will produce this plot

I'm leaving this open in case anyone wants to investigate further, but I can't see myself adding the functionality for zip codes in any near future.