[acs-r] Sort acs object before plotting?

Tiernan Martin tiernanmartin at gmail.com
Tue Oct 25 19:26:15 EDT 2016


Works like a charm! I included a couple examples so folks can see the
benefit.

Thanks, Ezra.

*Ordered by Estimate*
[image: acs-ex-ordered1.png]
*Ordered by Standard Error*

*[image: acs-ex-ordered2.png]*

On Tue, Oct 25, 2016 at 11:32 AM Ezra Haber Glenn <eglenn at mit.edu> wrote:

>
> Great question.  The trick would be to use order() as an index vector
> inside square brackets.  So if my.data is a acs object and you want to
> plot the first column, an unsorted plot would be:
>
> > plot(my.data[,1])
>
> and a sorted plot might be
>
> > plot(my.data[order(estimate(my.data[,1])),1])
>
> should do the trick.
>
> If you're doing a bunch of this sort of thing, or maybe if you want to
> plot one column based on the order of another (say, the percentage of
> commuters in a tract, by order of the median HH income of the tracts),
> you could save the indices:
>
> > my.index=order(estimate(my.data[,1]))
> > plot(my.data[my.index, 1])
>
> --Ezra
>
> On Tue, 25 Oct 2016 11:31:07 -0400, Tiernan Martin wrote:
> >
> > [1  <multipart/related (7bit)>]
> > [1.1  <multipart/alternative (7bit)>]
> > [1.1.1  <text/plain; UTF-8 (7bit)>]
> > [1.1.2  <text/html; UTF-8 (quoted-printable)>]
> > I love the plotting method that the acs package implements, but if an
> acs object has many
> > records the resulting graph can be difficult to understand (see below).
> >
> > acs-grap
> >
> > Is there a good way for arranging the records so that the graph shows
> them in ascending
> > order? My efforts to use `sort()` and `dplyr::arrange()` have all
> resulted in errors.
> >
> > Thanks,
> >
> > Tiernan
> >
> >
> > [2  <text/plain; us-ascii (7bit)>]
> > _______________________________________________
> > acs-r mailing list
> > acs-r at mit.edu
> > http://mailman.mit.edu/mailman/listinfo/acs-r
>
> --
> Ezra Haber Glenn, AICP
> Department of Urban Studies and Planning
> Massachusetts Institute of Technology
> 77 Massachusetts Ave., Room 7-346
> Cambridge, MA 02139
> eglenn at mit.edu
> http://dusp.mit.edu/faculty/ezra-glenn |
> http://eglenn.scripts.mit.edu/citystate/
> 617.253.2024 <(617)%20253-2024> (w)
> 617.721.7131 <(617)%20721-7131> (c)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/acs-r/attachments/20161025/1536497d/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: acs-ex-ordered1.png
Type: image/png
Size: 53182 bytes
Desc: not available
Url : http://mailman.mit.edu/pipermail/acs-r/attachments/20161025/1536497d/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: acs-ex-ordered2.png
Type: image/png
Size: 67005 bytes
Desc: not available
Url : http://mailman.mit.edu/pipermail/acs-r/attachments/20161025/1536497d/attachment-0003.png


More information about the acs-r mailing list