Uncategorized

Quick update: acs 2.1.1 now available

Posted by Ezra Glenn on July 24, 2017
Uncategorized / No Comments

Summary: acs v.2.1.0 users who are experiencing problems with acs.fetch (especially on windows) may want to consider updating to version 2.1.1, now on CRAN.

Shortly after releasing acs version 2.1.0, I’d heard from some Windows users that the package was unable to connect to the API to fetch data. After troubleshooting a bit, it became clear that the problem stemmed from the package’s switch to https (which will be required by the Census API in late summer) and its reliance on the RCurl package, which didn’t seem to be playing nicely with Windows https and TLS authentication. Sorry!

To address the issue I’ve modified the package to use the httr package instead of RCurl, which I am told works better. CRAN confirms that this seemed like a wise approach, and some initial user testing confirms this – thanks, user community! The new version (2.1.1) is now live on CRAN; windows binaries expected soon.

If you’ve recently installed or updated to 2.1.0 and the functions are working for you, no need to update again; if you’re getting errors when trying to fetch data, I’d recommend you run another update:

> update.packages("acs", clean=T)

Don’t forget to reinstall or “api.key.migrate()” your api key if it doesn’t seem to have been migrated during install. I also strongly recommend you run “acs.tables.install()” as well – you only need to do this once per installation (or update), and it will really speed up the package.

API Update: Back online now (3/27/2016)

Posted by Ezra Glenn on March 27, 2016
Uncategorized / Comments Off on API Update: Back online now (3/27/2016)

Update: the API seems to be back up. Sorry for the outage, and fetch away!

API Update: Unexplained Census API Outage, 3/26/2016

Posted by Ezra Glenn on March 26, 2016
Uncategorized / Comments Off on API Update: Unexplained Census API Outage, 3/26/2016

Warning:

For some reason, the census API seems to be down today (Sat March 26, 2016), so you may be getting errors when you try to fetch data. They look like this:

Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
No data found at:
  http://api.census.gov/data/2014/acs5?... [with lots more stuff here]

The error has nothing to do with the acs package or R, but is a census-side problem. To my knowledge, the API has been pretty reliable, so let’s hope it’s back up soon. Sorry for any problems all the same.

acs version 1.3: test-drive it now

Posted by Ezra Glenn on March 06, 2016
Uncategorized / Comments Off on acs version 1.3: test-drive it now

After far too long, we are nearing completion of version 1.3 of the acs package. As a special benefit to our loyal readers on CityState and members of the the acs.R mailing list,1 we are making available a special sneak-peak, pre-release version for you to try out. The biggest improvement is full support for all ACS, SF1, and SF3 data currently available via the Census API, including ACS data from 2005-2014 and Decennial data from 1990, 2000, and 2010. (See below for more info.)

Continue reading…

ACS 2010-2014 Data Now Available

Posted by Ezra Glenn on December 04, 2015
Uncategorized / Comments Off on ACS 2010-2014 Data Now Available

Just in time for the holidays, the Census has released new American Community Survey data, covering all states, counties, cities, and towns, down to the census tract and block-group level for the 2010–2014 five-year period. Luckily, the data is also available via the Census Census API, which mean it is available to users of the the acs.R package (version 1.2 or later; if you’re not sure which version you are using, you can always type packageVersion(“acs”) to find out.)

To get the latest data, just continue to use the acs.fetch() function as usual, but specify endyear=2014.1 Also, be aware that the function will give you some warnings about how “As of the date of this version of the acs package Census API did not provides data for selected endyear” – but you can safely ignore that, and the data will still be fetched.

Happy downloading!

Footnotes:

1

Note that by default, endyear is set to 2011 if no year is explicitly passed to acs.fetch, and I didn’t want to change this for fear of breaking existing user scripts. In the future, we might to rethink this, so that it selects the most recent endyear by default.

Making maps with ACS data

Posted by Ezra Glenn on August 26, 2015
Uncategorized / Comments Off on Making maps with ACS data

A new blog post on RevolutionAnalytics describes a way to use the acs.R and choroplethr packages in R to make maps based on data from the US Census American Community Survey. Click here for more.

A user asks…: acs.R and the 2013 census data

Posted by Ezra Glenn on August 17, 2015
Uncategorized / Comments Off on A user asks…: acs.R and the 2013 census data

An acs.R user asks:

Are there any plans for 2013 data to be incorporated into the acs
package?

Great question. Here is a great answer:

At present, the package is actually able to fetch the 2013 5-year ACS data, with two important caveats:

  1. you must specify the table number or variable number directly – you can’t use keywords, since the current version of the package lacks the correct lookup tables for 2013; and
  2. the acs.fetch function will give you some warnings about how “As of the date of this version of the acs package Census API did not provides data for selected endyear” – but you can safely ignore that.

See below for a basic example. (This said, I do want to release an updated version soon that will include the lookup tables and avoid the warnings.)

> acs.fetch(geography=geo.make(state=25, county="*"), table.number="B01003", endyear=2013)
ACS DATA: 
 2009 -- 2013 ;
  Estimates w/90% confidence intervals;
  for different intervals, see confint()
                                 B01003_001   
Barnstable County, Massachusetts 215449 +/- 0 
Berkshire County, Massachusetts  130545 +/- 0 
Bristol County, Massachusetts    549870 +/- 0 
Dukes County, Massachusetts      16739 +/- 0  
Essex County, Massachusetts      750808 +/- 0 
Franklin County, Massachusetts   71408 +/- 0  
Hampden County, Massachusetts    465144 +/- 0 
Hampshire County, Massachusetts  159267 +/- 0 
Middlesex County, Massachusetts  1522533 +/- 0
Nantucket County, Massachusetts  10224 +/- 0  
Norfolk County, Massachusetts    677296 +/- 0 
Plymouth County, Massachusetts   497386 +/- 0 
Suffolk County, Massachusetts    735701 +/- 0 
Worcester County, Massachusetts  802688 +/- 0 
Warning messages:
1: In acs.fetch(geography = geo.make(state = 25, county = "*"), table.number = "B01003",  :
  As of the date of this version of the acs package
  Census API did not provides data for selected endyear
2: In acs.fetch(endyear = endyear, span = span, geography = geography[[1]],  :
  As of the date of this version of the acs package
  Census API did not provides data for selected endyear

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="*")
> some.data=acs.fetch(geography=some.geo, table.number="B01003")

Check out the geography functions:

> head(geography(some.data))
> 

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(some.data)[-1]” will do the trick.)

> my.fips.codes=apply(X=geography(some.data)[-1], MARGIN=1, FUN=paste, collapse="")
> 

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

> geography(some.data)=cbind(my.fips.codes, geography(some.data))
> 

Now try:

> head(some.data)
ACS DATA: 
 2007 -- 2011 ;
  Estimates w/90% confidence intervals;
  for different intervals, see confint()
          B01003_001  
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.)