Monthly Archives: October 2014

acs.R Question: using FIPS codes as rownames

Posted by Ezra Glenn on October 28, 2014
Uncategorized / Comments Off on acs.R Question: using FIPS codes as rownames

Q: An acs.R user asks:

Is it possible for an acs object to use FIPS codes for rownames?

A: Absolutely. Here’s how:

Start with some data:

> some.geo=geo.make(state=25, county=001, tract="*")
>, table.number="B01003")

Check out the geography functions:

> head(geography(

The output of the final command should display the start of a dataframe with descriptive titles in the first column, but then fips codes for the state, county, and tract. When displaying acs objects, the first column of the object’s geography() dataframe is automatically used to name the rows. But this can be changed – see ?geography.

To use FIPS codes instead, we can extract the relevant columns from the object’s geography() and paste them together to recreate fully qualified FIPS codes. (The relevant columns are everything expect the first one, so “geography([-1]” will do the trick.)

>[-1], MARGIN=1, FUN=paste, collapse="")

Then we can re-assign the object’s geography() to include these codes as the first column:

> geography(, geography(

Now try:

> head(
 2007 -- 2011 ;
  Estimates w/90% confidence intervals;
  for different intervals, see confint()
251010100 2994 +/- 13 
251010206 2858 +/- 256
251010208 1903 +/- 260
251010304 2395 +/- 269
251010306 2616 +/- 270
251010400 3056 +/- 296

and you should see FIPS codes as the rownames.

Important note: Given that I actually don’t work with FIPS codes all that often, there is a chance I’ve deviated slightly from the proper formatting here – you may need to paste in extra leading zeroes or something to make sure the pieces line up in that apply/paste command – but hopefully you get the idea. (For example, I think tract IDs are supposed to be six digits long, not three.)

acs.R useRs: Share your success stories

Posted by Ezra Glenn on October 20, 2014
Census, Code, Free Software, Open-Source / Comments Off on acs.R useRs: Share your success stories

Have you been using the acs.R package to download and analyze Census data in your work? Do you have a story you’d be willing to share, to help us promote the package and show off all the cool ways people are using open source tools to make sense of data and help inform communities, policy-makers, and researchers? If so, please let us know: email your news or project descriptions to and we’ll post them here to inform and inspire our readers. Be sure to include good images, news coverage, quotations, or other materials to help tell the story — and feel free to include links, scripts, or examples as well.


PS: Don’t forget to subscribe to the acs.R mailing list to remain in touch with the growing acs.R user community.