|# data from http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat|
|# Originally seen at http://spatial.ly/2014/08/population-lines/|
|# So, this blew up on both Reddit and Twitter. Two bugs fixed (southern Spain was a mess,|
|# and some countries where missing -- measure twice, submit once, damnit), and two silly superflous lines removed after|
|# @hadleywickham pointed that out. Also, switched from geom_segment to geom_line.|
|# The result of the code below can be seen at http://imgur.com/ob8c8ph|
|mutate(lat = as.numeric(gsub('.*N([0-9]+)[EW].*', '\\1', GRD_ID))/100,|
|lng = as.numeric(gsub('.*[EW]([0-9]+)', '\\1', GRD_ID)) * ifelse(gsub('.*([EW]).*', '\\1', GRD_ID) == 'W', -1, 1) / 100) %>%|
|filter(lng > 25, lng < 60) %>%|
|group_by(lat=round(lat, 1), lng=round(lng, 1)) %>%|
|summarize(value = sum(TOT_P, na.rm=TRUE)) %>%|
|complete(lat, lng) %>%|
|ggplot(aes(lng, lat + 5*(value/max(value, na.rm=TRUE)))) +|
|geom_line(size=0.4, alpha=0.8, color='#5A3E37', aes(group=lat), na.rm=TRUE) +|
|ggsave('/tmp/europe.png', width=10, height=10)|
Very nice. Thanks.
Gotta love Iceland!
Neat! I've been playing around with this tonight and it's quite interesting. Some questions:
After investigating the data itself, I think it can be improved speed wise quite a bit since it's so big.
I was trying to figure out a clever
Thanks for making this. I've been meaning to dive deeper into Hadley's magical land of
@p0bs: I don't think rounding to 2 decimals does anything. When
IIRC, yes. Prefixing with
Oh, no, on the contrary. I write 10-30 line
http://r4ds.had.co.nz/ . Buy it, read it, practice. Tidyverse is a gift from heaven.