Comments (5)
Definitely. I'll keep this on the radar for version 0.4 which will default to the new 2012-2016 ACS estimates (when they come out).
from tidycensus.
That's fair. In my use case, I'm pulling ~30 variables. I actually attempted to left_join()
a conversion table, but I kept getting a select less than one feature in get1index
error. The workaround that finally solved the problem was to convert the sf object to a data frame, do the join, and then st_as_sf()
to get it back.
That's unlikely to be a problem with tidyverse, but it would be nice to automate. I do get your design philosophy, though. Thanks for the consideration.
from tidycensus.
I've pushed this functionality in 83dfe95. The way this works is by supplying a named vector to the variables
parameter in either get_acs()
or get_decennial()
. For example:
library(tidycensus)
pop10 <- get_decennial(geography = "state", variables = c(totalpop = "P0010001"))
head(pop10)
# A tibble: 6 x 4
GEOID NAME variable value
<chr> <chr> <chr> <dbl>
1 01 Alabama totalpop 4779736
2 02 Alaska totalpop 710231
3 04 Arizona totalpop 6392017
4 05 Arkansas totalpop 2915918
5 06 California totalpop 37253956
6 08 Colorado totalpop 5029196
Or:
d15 <- get_acs(geography = "state", variables = c(totalpop = "B01003_001", medinc = "B19013_001"))
head(d15)
# A tibble: 6 x 5
GEOID NAME variable estimate moe
<chr> <chr> <chr> <dbl> <dbl>
1 01 Alabama totalpop 4830620 NA
2 01 Alabama medinc 43623 281
3 02 Alaska totalpop 733375 NA
4 02 Alaska medinc 72515 838
5 04 Arizona totalpop 6641928 NA
6 04 Arizona medinc 50255 211
And in wide form:
d15wide <- get_acs(geography = "state",
variables = c(totalpop = "B01003_001", medinc = "B19013_001"),
output = "wide")
head(d15wide)
# A tibble: 6 x 6
totalpopE totalpopM medincE medincM NAME GEOID
<dbl> <dbl> <dbl> <dbl> <chr> <chr>
1 4830620 NA 43623 281 Alabama 01
2 733375 NA 72515 838 Alaska 02
3 6641928 NA 50255 211 Arizona 04
4 2958208 NA 41371 247 Arkansas 05
5 38421464 NA 61818 156 California 06
6 5278906 NA 60629 252 Colorado 08
@dkyleward would you mind testing and letting me know if this meets your needs, or if you have any suggestions?
from tidycensus.
I'll keep this in mind for the next release, though dplyr already handles this quite well. One of my design philosophies with tidycensus is to return data in the right format for manipulation within the tidyverse, but let the tidyverse packages do what they do best. As such:
inc <- get_acs(geography = "state", variables = "B19013_001") %>%
mutate(variable = recode(variable, B19013_001 = "hhincome"))
or:
inc <- get_acs(geography = "state", variables = "B19013_001",
output = "wide") %>%
rename(hhinc_est = B19013_001E, hhinc_moe = B19013_001M)
isn't that much more code, and gives users explicit control over what they are doing.
from tidycensus.
Perfect, thank you!
from tidycensus.
Related Issues (20)
- Bug with get_estimates and 2021 vintage data HOT 8
- Possible Issue with get_decennial block level variables HOT 1
- Conversion of East and West longitudes for US Census Tract 02016 in Alaska HOT 2
- Question: ACS 2018-2022 HOT 2
- 2022 ACS will require 2023 TIGER geometries for congressional districts HOT 3
- Need to update `geography` column for 2018-2022 ACS variables
- get_acs() - Is there a limit of ZCTAs one can pass for the zcta argument given geography="zcta"? HOT 1
- "dp" dataset not working HOT 2
- Clarify replicate weights method for pums data HOT 3
- "HISP" breakdown labels in `get_estimates(geography = "state")` return miscoded HOT 2
- `puma` argument not working with 5-year 2018-2022 ACS PUMS HOT 7
- get_pums and/or Census API issue HOT 4
- Add documentation to load_variables() about datasets
- geography column empty for load_variables() for 2022 ACS 5-year estimate variables HOT 1
- return_vacant and 'VACS' variable not working for get_pums HOT 4
- Failed with error: ‘lazy-load database 'C:/R/win-library/4.0/tidycensus/data/Rdata.rdb' is corrupt’ HOT 2
- rate_sleep() error HOT 2
- `tidycensus::get_acs()` does not have the limitations that `tigris::zctas()` does for specifying `state` for a given `year`
- Pulling from multiple source tables with `get_acs()` causes erroneous NAs HOT 2
- Feature request to make "Margin of Error" optional in get_acs(). HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tidycensus.