Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-14 Thread Ray Brownrigg
On 14/01/2012 10:33 a.m., Dimitri Liakhovitski wrote: Somewhat related question out of curiousity: Does anyone know how often the list of the counties and county names is updated in this package? Or is it done centrally for all packages that deal with US counties? Thanks! Dimitri Well, I would

[R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Dimitri Liakhovitski
Dear Rers, is there a way to color counties on a full US map based on a criterion one establishes (i.e., all counties I assign the same number should be the same color)? I explored a bit and looks like the package maps might be of help. library(maps) One could get a map of the US: map('usa') One

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Sarah Goslee
Hi, You've just about got it. See below. On Fri, Jan 13, 2012 at 11:52 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Dear Rers, is there a way to color counties on a full US map based on a criterion one establishes (i.e., all counties I assign the same number should be the

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Dimitri Liakhovitski
Sarah, this is amazing, thank you so much. One question: I am trying to do for the whole US (on one map) what you've helped me do for Iowa. In other words, I would like to create a file of inputs like you countycol with 1,000+ lines - for all US counties (probably without Hawaii and Alaska,

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Sarah Goslee
On Fri, Jan 13, 2012 at 12:15 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Sarah, this is amazing, thank you so much. One question: I am trying to do for the whole US (on one map) what you've helped me do for Iowa. In other words, I would like to create a file of inputs like

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Dimitri Liakhovitski
Thank you somuch, Sarah. I tried, and it's working just wonderfully (code below). One last question, if I may: is it possible to get rid of borders between counties (just leave the fill)? I did not find this argument in help... Thank you! Dimitri ### My criterion for all counties.:

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Dimitri Liakhovitski
Just to clarify, according to help about the fill argument: logical flag that says whether to draw lines or fill areas. If FALSE, the lines bounding each region will be drawn (but only once, for interior lines). If TRUE, each region will be filled using colors from the col = argument, and bounding

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Sarah Goslee
On Fri, Jan 13, 2012 at 1:41 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Thank you somuch, Sarah. I tried, and it's working just wonderfully (code below). One last question, if I may: is it possible to get rid of borders between counties (just leave the fill)? I did not find

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Sarah Goslee
On Fri, Jan 13, 2012 at 1:52 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Just to clarify, according to help about the fill argument: logical flag that says whether to draw lines or fill areas. If FALSE, the lines bounding each region will be drawn (but only once, for

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Dimitri Liakhovitski
But the help does say that additional arguments are passed to lines(), so you can use lty=0. That can leave white bits between counties if the areas don't line up precisely, so I think it looks better with the lines in black. I agree, indeed it leaves white bits. Of course, I could try to

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Sarah Goslee
Changing the color of the borders is what the border argument to polygon() would do, if only it hadn't been overridden. So no, you can't easily change the line color. It would be an easy tweak to the code to add a polyborder argument that is passed to polygon() as border, though. That would solve

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread David L Carlson
You can set the fg graphics parameter, for example oldpar - par(fg='white') # change the default fg (foreground color) to white map('county', 'iowa', fill=TRUE, col='light gray') oldpar # reset fg to the default - black map('state', 'iowa', lwd=3, add=TRUE) Assuming you want the state outline in

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Dimitri Liakhovitski
Sarah, David, thank you very much for your help! It all works now: ### My criterion for all counties: allcounties-data.frame(county=map('county', plot=FALSE)$names) allcounties$group-c(rep(1:6,513),rep(1,4))[order(c(rep(1:6,513),rep(1,4)))] ### My colors: classcolors - rainbow(6) ### For gray

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Ray Brownrigg
On 14/01/2012 8:04 a.m., Sarah Goslee wrote: On Fri, Jan 13, 2012 at 1:52 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Just to clarify, according to help about the fill argument: logical flag that says whether to draw lines or fill areas. If FALSE, the lines bounding each

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Sarah Goslee
Hi Ray, I'm glad to see you here. I was going to write this up a bit more clearly and email it to you, but now I don't have to bother. :) Coincidentally, I became aware of this just recently.  When the maps package was created (way back in the 'new' S era), polygon() didn't add borders, and

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Dimitri Liakhovitski
Everyone, thanks a lot - this is great: ### My criterion for all counties: allcounties-data.frame(county=map('county', plot=FALSE)$names) allcounties$group-c(rep(1:6,513),rep(1,4))[order(c(rep(1:6,513),rep(1,4)))] ### My colors: classcolors - rainbow(6) ### 1. If I want to have no borders

Re: [R] Coloring counties on a full US map based on a certain criterion

2012-01-13 Thread Dimitri Liakhovitski
Somewhat related question out of curiousity: Does anyone know how often the list of the counties and county names is updated in this package? Or is it done centrally for all packages that deal with US counties? Thanks! Dimitri On Fri, Jan 13, 2012 at 3:41 PM, Ray Brownrigg