[acs-r] ACS 2.1
Laviolette, Michael
Michael.Laviolette at dhhs.nh.gov
Thu Jul 13 15:17:13 EDT 2017
I got the path to my extdata folder, but that's not where the table files went. To be sure, I deleted them and re-ran acs.table.install. The files were still copied to the wrong location.
-----Original Message-----
From: Ezra Haber Glenn [mailto:eglenn at mit.edu]
Sent: Thursday, July 13, 2017 3:00 PM
To: Laviolette, Michael
Cc: acs-r at mit.edu
Subject: Re: [acs-r] ACS 2.1
They should be in the package's extdata file, but now you've got me worried it's a windows thing. What do you get when you run this is R:
paste(system.file(package="acs"), "extdata", sep="/")
?
On Thu, 13 Jul 2017 14:52:47 -0400, Laviolette, Michael wrote:
>
> [1 <text/plain; utf-8 (base64)>]
> [2 <text/html; utf-8 (base64)>]
> When you run acs.tables.install(), where are the table files supposed
> to go? I found them in the main acs package folder; I would have
> expected them in the extdata folder where the key is stored.
>
> Michael Laviolette PhD MPH
>
> Public Health Statistician
>
> Bureau of Public Health Statistics and Informatics
>
> New Hampshire Division of Public Health Services
>
> 29 Hazen Drive
>
> Concord, NH 03301-6504
>
> Phone: 603-271-5688
>
> Email: Michael.Laviolette at dhhs.nh.gov
>
> "Improving Health, Preventing Disease, Reducing Costs for All"
>
> From: acs-r-bounces at mit.edu [mailto:acs-r-bounces at mit.edu] On Behalf
> Of Ezra Haber Glenn
> Sent: Thursday, July 13, 2017 12:53 PM
> To: acs-r at mit.edu; Sara Hintze
> Cc: 'acs-r at mit.edu'
> Subject: Re: [acs-r] ACS 2.1
>
> Ps, can you also confirm that you've reinstalled your api key?
>
> On July 13, 2017 12:43:52 PM EDT, Ezra Haber Glenn <eglenn at mit.edu> wrote:
>
> There have been some issues with the online variable lookup tables
> that the package needs to access. Can you try this function (just
> once -- no need to use it every time) :
>
> acs.tables.install()
>
> after that, see if your script works.
>
> Thanks.
>
> --Ezra
>
> On Thu, 13 Jul 2017 12:33:39 -0400, Sara Hintze wrote:
>
> [1 <multipart/alternative (7bit)>]
> [1.1 <text/plain; us-ascii (quoted-printable)>]
> [1.2 <text/html; us-ascii (quoted-printable)>] Hi all,
>
> I recently upgraded from acs 2.0 to 2.1 and am receiving errors from
> a script that previously worked under acs 2.0. I’ve attached the
> original script along with the console output. Have I missed something obvious and/or has anyone else had similar issues?
>
> Thanks,
>
> Sara
>
> Sara Hintze
>
> GIS Data Developer/Analyst | Research Services
>
> Mid-America Regional Council
>
> 600 Broadway Blvd., Ste 200
>
> Kansas City, MO 64105
>
> 816-701-8220 | www.marc.org
>
> [2 Script.r <application/octet-stream (base64)>]
> [3 ConsoleOutput.txt <text/plain (base64)>]
>
> # Call the acs package for data processing
> library(acs)
>
> Loading required package: stringr
> Loading required package: XML
>
> Attaching package: ‘acs’
>
> The following object is masked from ‘package:base’:
>
> apply
>
> Warning message:
> package ‘acs’ was built under R version 3.3.3
>
> # Variables to specify end year of ACS to pull from, as well as the
> span, which specifies the estimates to pull for that end year (1-year,
> 3-year, or 5-year), and the geographic level year_endyear = 2015
> year_span = 5 # 1-year estimates are not available at the tract or block group level fileGeo = "County"
>
> # Additional geography fields for output countyFIPS = ""
> countyName = ""
> stateFIPS = ""
> stateAbbr = ""
>
> if (fileGeo == "BlockGroup") {
>
> + # Block Group Geographies
> + mo.geo=geo.make(state=29,
> county=c(3,13,21,25,37,47,49,63,95,101,107,165,177), tract="*",
> block.group="*") + ks.geo=geo.make(state=20,
> county=c(1,5,43,45,59,91,103,107,121,209), tract="*", block.group="*")
> + + # Combine the Missouri and Kansas geographies, so we're pulling
> all data in a single request + geo = mo.geo + ks.geo + } else if
> (fileGeo == "Tract") { + # Tract Geographies:
> + mo.geo=geo.make(state=29,
> county=c(3,13,21,25,37,47,49,63,95,101,107,165,177), tract="*") +
> ks.geo=geo.make(state=20, county=c(1,5,43,45,59,91,103,107,121,209),
> tract="*") + + # Combine the Missouri and Kansas geographies, so
> we're pulling all data in a single request + geo = mo.geo + ks.geo +
> } else if (fileGeo == "Place") { + # Place Geographies:
> + mo.geo=geo.make(state=29, place="*") + ks.geo=geo.make(state=20,
> place="*") + + # Combine the Missouri and Kansas geographies, so
> we're pulling all data in a single request + geo = mo.geo + ks.geo +
> } else if (fileGeo == "County") { + # County Geographies:
> + # Top 2 are for counties in the MSA, plus counties needed for REACH
> data (Allen County, KS and Lafayette County, MO)] + # Bottom 2 are
> the counties in the MARC region only + + #All Counties in the CSA
> (??) (plus Allen County, KS) + if (year_span == 5){ +
> mo.geo=geo.make(state=29,
> county=c(3,13,21,25,37,47,49,63,95,101,107,165,177))
> + ks.geo=geo.make(state=20,
> county=c(1,5,43,45,59,91,103,107,121,209))
> + } else {
> + #Counties Available within the 1-Year ACS Estimates +
> mo.geo=geo.make(state=29, county=c(21,37,47,95,165)) +
> ks.geo=geo.make(state=20, county=c(45,91,103,209)) + } + + #
> Combine the Missouri and Kansas geographies, so we're pulling all data
> in a single request + geo = mo.geo + ks.geo + } else if (fileGeo ==
> "MSA") { + # MSA Geographies - cannot be pulled by County or State,
> so getting all + geo <- geo.make(msa="*") + # Set the stateFIPS so
> that data appends correctly + stateFIPS = 99 + }
>
> # Clean up variables that are no longer needed.
> if (fileGeo != "MSA") {
>
> + rm(mo.geo, ks.geo)
> + }
>
> # Set up acs.lookup objects for data we want to retrieve
> population.under18 = acs.lookup(table.name = "B09001",
> span=year_span, endyear = year_endyear)
>
> trying URL 'http://web.mit.edu/eglenn/www/acs/acs-variables/acs_5yr_2015_var.xml.gz'
> Content type 'application/xml' length 735879 bytes (718 KB)
> downloaded 718 KB
>
> Warning message:
> In acs.lookup(table.name = "B09001", span = year_span, endyear = year_endyear) :
> XML variable lookup tables for this request
> seem to be missing from ' https://api.census.gov/data/2015/acs5/variables.xml ';
> temporarily downloading and using archived copies instead;
> since this is *much* slower, recommend running
> acs.tables.install()
>
> ownChildren.byFamilyType = acs.lookup(table.name="B09002",
> span=year_span, endyear=year_endyear)
>
> trying URL 'http://web.mit.edu/eglenn/www/acs/acs-variables/acs_5yr_2015_var.xml.gz'
> Content type 'application/xml' length 735879 bytes (718 KB)
> downloaded 718 KB
>
> Warning message:
> In acs.lookup(table.name = "B09002", span = year_span, endyear = year_endyear) :
> XML variable lookup tables for this request
> seem to be missing from ' https://api.census.gov/data/2015/acs5/variables.xml ';
> temporarily downloading and using archived copies instead;
> since this is *much* slower, recommend running
> acs.tables.install()
>
> # Select out just those variables we want population.under18.vars =
> population.under18[1:10] ownchildren.byfamilytype.vars =
> ownChildren.byFamilyType[1:20] children.vars =
> population.under18.vars + ownchildren.byfamilytype.vars
>
> # Request/fetch the data, and then add to a dataframe for output
> children.data = acs.fetch(endyear=year_endyear, span=year_span,
> geography=geo, variable=children.vars, dataset="acs")
>
> Error in if (url.test["statusMessage"] != "OK") { :
> missing value where TRUE/FALSE needed
>
> # Create a complete FIPS code ID for the block group, tract, place,
> or county - this is what is used to join this data to geography if
> (fileGeo == "Tract") {
>
> + myFIPS = paste(geography(children.data)$state,
> sprintf("%03d",geography(children.data)$county),
> geography(children.data)$tract, sep="") + } else if (fileGeo ==
> "County") { + myFIPS = paste(geography(children.data)$state,
> sprintf("%03s",geography(children.data)$county), sep="") + } else if
> (fileGeo == "Place") { + myFIPS =
> paste(geography(children.data)$state,
> sprintf("%05s",geography(children.data)$place), sep="") + } else if
> (fileGeo == "BlockGroup") { + myFIPS =
> paste(geography(children.data)$state,
> sprintf("%03d",geography(children.data)$county),
> sprintf("%06d",geography(children.data)$tract),
> geography(children.data)$blockgroup, sep="") + } else if (fileGeo ==
> "MSA") { + myFIPS =
> geography(children.data)$metropolitanstatisticalareamicropolitanstatis
> ticalarea
> + }
> Error in geography(children.data) : object 'children.data' not found
>
> if (fileGeo != "MSA" && fileGeo != "Place") {
>
> + countyFIPS = paste(geography(children.data)$state,
> sprintf("%03s",geography(children.data)$county), sep="") + stateFIPS
> = geography(children.data)$state + } else if(fileGeo != "MSA") { +
> stateFIPS = geography(children.data)$state + } Error in
> geography(children.data) : object 'children.data' not found
>
> children.df = data.frame(geography(children.data)$NAME, myFIPS,
> countyFIPS, countyName, stateFIPS, stateAbbr, year_endyear, year_span,
> estimate(children.data))
>
> Error in geography(children.data) : object 'children.data' not found
>
> # Overwrite default ACS field names with English cols_children =
> c("GeoStr", "FIPS", "CountyFIPS", "CountyName", "StateFIPS",
> "StateAbbr", "Period", "Dataset", "PopulationUnder18",
> "Under18InHouseholds", "AgeUnder3Years", "Age3to4", "Age5", "Age6to8",
> "Age9to11", "Age12to14", "Age15to17", "Under18InGroupQuarters",
> "OwnChildrenUnder18",
> "InMarriedCouples","InMarriedCouples_Under3years","InMarriedCouples_3t
> o4years","InMarriedCouples_5years","InMarriedCouples_6to11years","InMa
> rriedCouples_12to17years","InOtherFamilies","MaleHoH","MaleHoH_Under3y
> ears","MaleHoH_3to4years","MaleHoH_5years","MaleHoH_6to11years","MaleH
> oH_12to17years","FemaleHoH","FemaleHoH_Under3years","FemaleHoH_3to4yea
> rs","FemaleHoH_5years","FemaleHoH_6to11years","FemaleHoH_12to17years")
> colnames(children.df)=cols_children
>
> Error in colnames(children.df) = cols_children :
> object 'children.df' not found
>
> # Set rownames to NULL, so it defaults to a sequential numeric output
> rownames(children.df) <- NULL
>
> Error in rownames(children.df) <- NULL : object 'children.df' not
> found
>
> #Clean up unneeded variables
> rm(ownChildren.byFamilytype, ownchildren.byfamilytype.vars,
> population.under18, population.under18.vars, children.vars,
> children.data, children.df)
>
> Warning messages:
> 1: In rm(ownChildren.byFamilytype, ownchildren.byfamilytype.vars, population.under18, :
> object 'ownChildren.byFamilytype' not found
> 2: In rm(ownChildren.byFamilytype, ownchildren.byfamilytype.vars, population.under18, :
> object 'children.data' not found
> 3: In rm(ownChildren.byFamilytype, ownchildren.byfamilytype.vars, population.under18, :
> object 'children.df' not found
>
> [4 <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
> 617.253.2024 (w)
> 617.721.7131 (c)
>
> ----------------------------------------------------------------------
> --------------------
>
> acs-r mailing list
> acs-r at mit.edu
> http://mailman.mit.edu/mailman/listinfo/acs-r
>
> --
> Ezra Haber Glenn
> Department of Urban Studies and Planning Massachusetts Institute of
> Technology eglenn at mit.edu / 617.721.7131
>
>
--
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
617.253.2024 (w)
617.721.7131 (c)
More information about the acs-r
mailing list