Grokbase Groups R r-help October 2011
FAQ
Hi, I would like to make a plot of the US states (or lower 48) that are
colored based upon a percentage change column. Ideally, it would gradually
be more blue the larger the positive change, and more red the more negative
is the change.

The data I have looks like:

State Percent.Change
1 Alabama 0.004040547
2 Alaska -0.000202211
3 Arizona -0.002524567
4 Arkansas -0.008525333
5 California 0.001828754
6 Colorado 0.011116150

I have read help for the maps library and similar plots online but can't
grasp how to map the percentage.change column to the map. thank in advance,

Michael Bailey

Search Discussions

  • Paul Hiemstra at Oct 13, 2011 at 7:24 am

    On 10/13/2011 12:45 AM, Michael Charles Bailey I wrote:
    State Percent.Change
    1 Alabama 0.004040547
    2 Alaska -0.000202211
    3 Arizona -0.002524567
    4 Arkansas -0.008525333
    5 California 0.001828754
    6 Colorado 0.011116150
    Hi,

    Please provide a reproducible example (up to the point where you are
    stuck), as suggested in the posting guide.

    good luck,
    Paul

    --
    Paul Hiemstra, Ph.D.
    Global Climate Division
    Royal Netherlands Meteorological Institute (KNMI)
    Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
    P.O. Box 201 | 3730 AE | De Bilt
    tel: +31 30 2206 494

    http://intamap.geo.uu.nl/~paul
    http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
  • Jim Lemon at Oct 13, 2011 at 8:20 am

    On 10/13/2011 11:45 AM, Michael Charles Bailey I wrote:
    Hi, I would like to make a plot of the US states (or lower 48) that are
    colored based upon a percentage change column. Ideally, it would gradually
    be more blue the larger the positive change, and more red the more negative
    is the change.

    The data I have looks like:

    State Percent.Change
    1 Alabama 0.004040547
    2 Alaska -0.000202211
    3 Arizona -0.002524567
    4 Arkansas -0.008525333
    5 California 0.001828754
    6 Colorado 0.011116150

    I have read help for the maps library and similar plots online but can't
    grasp how to map the percentage.change column to the map. thank in advance,
    Hi Michael,
    I do a similar thing like this:

    SEIFAcol<-color.scale(AU_SEIFA$SEIFA1dec[1:199],
    c(1,0.9,0.8,0.8),c(0.8,0.9,0.9,0.8),c(0.8,0.8,0.9,1),xrange=c(1,10))
    ...
    plot(NSWmap,xlim=c(140,max(cdrt09$GeocodeX,na.rm=TRUE)),
    col=SEIFAcol)
    SEIFAlegendcol<-color.scale(1:10,
    c(1,0.9,0.8,0.8),c(0.8,0.9,0.9,0.8),c(0.8,0.8,0.9,1))
    color.legend(151.8,-37.5,152.3,-34.5,as.character(1:10),SEIFAlegendcol,
    align="rb",gradient="y")

    In this case, Statistical Local Areas are being colored on the Index of
    Relative Social Disadvantage. The call to color.scale calculates a color
    for each of the 199 SLAs based on their IRSD score. If you want to
    define different color scales for positive and negative values, see the
    help page for color.scale (plotrix).

    Jim
  • Greg Snow at Oct 13, 2011 at 6:28 pm
    Unless your audience is mainly interested in Texas and California and is completely content to ignore Rhode Island, then I would suggest that you look at the state.vbm map in the TeachingDemos package that works with the maptools package. The example there shows coloring based on a variable.

    --
    Gregory (Greg) L. Snow Ph.D.
    Statistical Data Center
    Intermountain Healthcare
    greg.snow at imail.org
    801.408.8111

    -----Original Message-----
    From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
    project.org] On Behalf Of Michael Charles Bailey I
    Sent: Wednesday, October 12, 2011 6:46 PM
    To: r-help at r-project.org
    Subject: [R] US States percentage change plot

    Hi, I would like to make a plot of the US states (or lower 48) that are
    colored based upon a percentage change column. Ideally, it would
    gradually
    be more blue the larger the positive change, and more red the more
    negative
    is the change.

    The data I have looks like:

    State Percent.Change
    1 Alabama 0.004040547
    2 Alaska -0.000202211
    3 Arizona -0.002524567
    4 Arkansas -0.008525333
    5 California 0.001828754
    6 Colorado 0.011116150

    I have read help for the maps library and similar plots online but
    can't
    grasp how to map the percentage.change column to the map. thank in
    advance,

    Michael Bailey

    [[alternative HTML version deleted]]

    ______________________________________________
    R-help at r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-
    guide.html
    and provide commented, minimal, self-contained, reproducible code.
  • Farley, Robert at Oct 13, 2011 at 6:43 pm
    OT question: can R produce Cartograms?

    Here's an example of World Population:
    http://www.worldmapper.org/display.php?selected=2


    This might make Texas smaller and Rhode Island larger....



    Robert Farley
    LACMTA

    -----Original Message-----
    From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Greg Snow
    Sent: Thursday, October 13, 2011 11:28
    To: Michael Charles Bailey I; r-help at r-project.org
    Subject: Re: [R] US States percentage change plot

    Unless your audience is mainly interested in Texas and California and is completely content to ignore Rhode Island, then I would suggest that you look at the state.vbm map in the TeachingDemos package that works with the maptools package. The example there shows coloring based on a variable.

    --
    Gregory (Greg) L. Snow Ph.D.
    Statistical Data Center
    Intermountain Healthcare
    greg.snow at imail.org
    801.408.8111

    -----Original Message-----
    From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
    project.org] On Behalf Of Michael Charles Bailey I
    Sent: Wednesday, October 12, 2011 6:46 PM
    To: r-help at r-project.org
    Subject: [R] US States percentage change plot

    Hi, I would like to make a plot of the US states (or lower 48) that are
    colored based upon a percentage change column. Ideally, it would
    gradually
    be more blue the larger the positive change, and more red the more
    negative
    is the change.

    The data I have looks like:

    State Percent.Change
    1 Alabama 0.004040547
    2 Alaska -0.000202211
    3 Arizona -0.002524567
    4 Arkansas -0.008525333
    5 California 0.001828754
    6 Colorado 0.011116150

    I have read help for the maps library and similar plots online but
    can't
    grasp how to map the percentage.change column to the map. thank in
    advance,

    Michael Bailey

    [[alternative HTML version deleted]]

    ______________________________________________
    R-help at r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-
    guide.html
    and provide commented, minimal, self-contained, reproducible code.
    ______________________________________________
    R-help at r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.
  • Yihui Xie at Oct 13, 2011 at 8:39 pm
    One package that you can use is Rcartogram from Omegahat, although it
    took me a long long time to figure out how to use it for real maps. I
    noticed there was another unpublished package named cart in R-Forge,
    and I have never tried it.

    I also want to know if there are other R packages that have as simple
    usage as "take the polygon coordinates and warp the polygons according
    to a variable". At least for Rcartogram, it is not so easy (due to the
    design of the C code by other authors). Maybe I'm going in a wrong
    direction (no cartogram algorithm is so straightforward?).

    Regards,
    Yihui
    --
    Yihui Xie <xieyihui@gmail.com>
    Phone: 515-294-2465 Web: http://yihui.name
    Department of Statistics, Iowa State University
    2215 Snedecor Hall, Ames, IA


    On Thu, Oct 13, 2011 at 1:43 PM, Farley, Robert wrote:
    OT question: can R produce Cartograms?

    Here's an example of World Population:
    http://www.worldmapper.org/display.php?selected=2


    This might make Texas smaller and Rhode Island larger....



    Robert Farley
    LACMTA

    -----Original Message-----
    From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Greg Snow
    Sent: Thursday, October 13, 2011 11:28
    To: Michael Charles Bailey I; r-help at r-project.org
    Subject: Re: [R] US States percentage change plot

    Unless your audience is mainly interested in Texas and California and is completely content to ignore Rhode Island, then I would suggest that you look at the state.vbm map in the TeachingDemos package that works with the maptools package. ?The example there shows coloring based on a variable.

    --
    Gregory (Greg) L. Snow Ph.D.
    Statistical Data Center
    Intermountain Healthcare
    greg.snow at imail.org
    801.408.8111

    -----Original Message-----
    From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
    project.org] On Behalf Of Michael Charles Bailey I
    Sent: Wednesday, October 12, 2011 6:46 PM
    To: r-help at r-project.org
    Subject: [R] US States percentage change plot

    Hi, I would like to make a plot of the US states (or lower 48) that are
    colored based upon a percentage change column. Ideally, it would
    gradually
    be more blue the larger the positive change, and more red the more
    negative
    is the change.

    The data I have looks like:

    ? ? ? ?State Percent.Change
    1 ? ?Alabama ? ?0.004040547
    2 ? ? Alaska ? -0.000202211
    3 ? ?Arizona ? -0.002524567
    4 ? Arkansas ? -0.008525333
    5 California ? ?0.001828754
    6 ? Colorado ? ?0.011116150

    I have read help for the maps library and similar plots online but
    can't
    grasp how to map the percentage.change column to the map. thank in
    advance,

    Michael Bailey

    ? ? ? [[alternative HTML version deleted]]

    ______________________________________________
    R-help at r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-
    guide.html
    and provide commented, minimal, self-contained, reproducible code.
    ______________________________________________
    R-help at r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.

    ______________________________________________
    R-help at r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupr-help @
categoriesr
postedOct 13, '11 at 12:45a
activeOct 13, '11 at 8:39p
posts6
users6
websiter-project.org
irc#r

People

Translate

site design / logo © 2017 Grokbase