Can you give me a for-instance of “populations”? Is there a table or chart or list or…
Also I guess that I should leave my R session on for as long as possible as “install.blk” takes a really long time to re-upload if that is what it is doing. Does install.blk go to the source every time? Thanks again. --- KW > On Aug 4, 2015, at 3:22 PM, Zack Almquist <almqu...@umn.edu> wrote: > > P.S. The US census has different "populations" (or worlds) so make sure the > housing variable you use is accessing the correct "world." > > Best, > > -- Zack > --------------------------------------------------------- > Zack W. Almquist > Assistant Professor > Department of Sociology and School of Statistics > Affiliate, Minnesota Population Center > University of Minnesota > > On Tue, Aug 4, 2015 at 2:12 PM, Zack Almquist <almqu...@umn.edu> wrote: > Hi Keith, > > > On Tue, Aug 4, 2015 at 12:43 PM, Keith S Weintraub <kw1...@gmail.com> wrote: > I had to download a bunch of stuff but I got it mostly working. > > Unfortunately using the alternative method I get the following: > > > housing<-CensusAPI2010(c("H0010001"), state.fips=state.fips, level = > > c("block"), key, summaryfile = c("sf1")) > Error in file(con, "r") : cannot open the connection > In addition: Warning message: > In file(con, "r") : cannot open: HTTP status was '400 Bad Request’ > > Sorry that is my bad, I didn't verify the variable name at > (http://api.census.gov/data/2010/sf1/variables.html). This seems to work for > me, as a quick test: > > housing<-CensusAPI2010(variables="H0060001", state.fips="06", level = > c("tract"), key, summaryfile = c("sf1")) > > So the larger example: > > ## Get all states fips code > data(countyfips) > state.fips<-unique(substr(countyfips$fips,1,2)) > head(state.fips) > length(state.fips) ## will be 51=50 (states)+ 1(DC) > ## You will need a census key > key<-"YOUR KEY HERE" > housing<-CensusAPI2010(c("H0060001"), state.fips=state.fips, level = > c("block"), key, summaryfile = c("sf1")) > > should work just fine. > > Best, > > -- Zack > --------------------------------------------------------- > Zack W. Almquist > Assistant Professor > Department of Sociology and School of Statistics > Affiliate, Minnesota Population Center > University of Minnesota > > I have a feeling that this is not a problem with the API. > > Thanks for your help, > KW > > > > > > > > > On Aug 3, 2015, at 2:12 PM, Zack Almquist <almqu...@umn.edu> wrote: > > > > Hi Anthony and Keith Weintraub, > > > > Here is a way to do what you are asking using the UScensus2010 packages: > > > > ## latest version of the package, not yet on CRAN > > install.packages("UScensus2010", repos="http://R-Forge.R-project.org") > > library(UScensus2010) > > install.blk() > > library(UScensus2010blk) > > ### You will want the H0010001 variable (see help(alabama.blk10)) > > ### Other variables are also available > > ### You can use the new api function in UScensus2010 to get arbitrary > > variables from SF1 and acs > > > > data(states.names) > > head(states.names) > > state.blk.housing<-vector("list",length(states.names)) > > ## notice this could be greatly spead up using the library(parallel) > > ## with mclapply > > ## This will be somewhat slow b/c of so much spatial data > > for(i in 1:length(states.names)){ > > data(list=paste(states.names[i],"blk10",sep=".")) > > temp<-get(paste(states.names[i],"blk10",sep=".")) > > #unique b/c more shapefiles than fips > > state.blk.housing[[i]]<-unique(temp@data[,c("fips","H0010001")]) > > print(i) > > rm(paste(states.names,"blk10",sep=".")) > > } > > > > ########### > > # alternatively Using the US Census API function in the new UScensus2010 > > package > > ########### > > > > ## Get all states fips code > > data(countyfips) > > state.fips<-unique(substr(countyfips$fips,1,2)) > > head(state.fips) > > length(state.fips) ## will be 51=50 (states)+ 1(DC) > > ## You will need a census key > > key<-"YOUR KEY HERE" > > housing<-CensusAPI2010(c("H0010001"), state.fips=state.fips, level = > > c("block"), key, summaryfile = c("sf1")) > > > > Best, > > > > -- Zack > > --------------------------------------------------------- > > Zack W. Almquist > > Assistant Professor > > Department of Sociology and School of Statistics > > Affiliate, Minnesota Population Center > > University of Minnesota > > > > > > On Mon, Aug 3, 2015 at 12:43 PM, Anthony Damico <ajdam...@gmail.com> wrote: > > hi, ccing the package maintainer. one alternative is to pull the HU100 > > variable directly from the census bureau's summary files: that variable > > starts at position 328 and ends at 336. just modify this loop and you'll > > get a table with one-record-per-census-block in every state. > > > > https://github.com/davidbrae/swmap/blob/master/how%20to%20map%20the%20consumer%20expenditure%20survey.R#L104 > > > > (1) line 134 change the very last -9 to 9 > > (2) line 137 between "pop100" and "intptlat" add an "hu100" > > > > > > summary file docs- > > > > http://www.census.gov/prod/cen2010/doc/sf1.pdf#page=18 > > > > > > > > On Mon, Aug 3, 2015 at 11:55 AM, Keith S Weintraub <kw1...@gmail.com> wrote: > > Folks, > > > > I am using the UScensus2010 package and I am trying to figure out the > > number of households per census block. > > > > There are a number of possible data downloads in the package but apparently > > I am not smart enough to figure out which data-set is appropriate and what > > functions to use. > > > > Any help or pointers or links would be greatly appreciated. > > > > Thanks for your time, > > Best, > > KW > > > > ______________________________________________ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.