tidycensus | Load US Census boundary and attribute data as 'tidyverse' and 'sf'-ready data frames in R | Data Visualization library
kandi X-RAY | tidycensus Summary
kandi X-RAY | tidycensus Summary
tidycensus is an R package that allows users to interface with the US Census Bureau's decennial Census and five-year American Community APIs and return tidyverse-ready data frames, optionally with simple feature geometry included. Install from CRAN with the following command:. To learn more about the package, please visit the package documentation at Note: This product uses the Census Bureau Data API but is not endorsed or certified by the Census Bureau.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of tidycensus
tidycensus Key Features
tidycensus Examples and Code Snippets
Community Discussions
Trending Discussions on tidycensus
QUESTION
I'm trying to write up a report and simply want to include a .jpeg image in my write up. However, whenever i knit together my document, I get the following error:
...ANSWER
Answered 2022-Mar-28 at 17:25I had the same issue and it seems you will need to pass the absolute path. See this .
Instead of using here
maybe try using normalizePath
in include_graphics
.
So omit your call here()
, which may not be propagating across chunks (I don't know, because I can't see your chunks), and do:
QUESTION
I tried to install the sf
package because it is a dependency for tidycensus
, which is the package I'd like to use.
I am using a Mac with Big Sur. Per the Github for r-spatial, I tried following the installation instructions here but no dice. My sessionInfo()
:
ANSWER
Answered 2022-Mar-23 at 00:59The solution, thanks to @IRTFM, was to download the binary from CRAN, then use R CMD INSTALL
. Then I could install tigris
and tidycensus
via install.packages()
QUESTION
How might I capture all the years of age in a column with values like "20 to 24 years" for one group and "22 to 24 years" for another group? This will enable me to confirm I have all the working age (18-64) variable names captured in a tidycensus (R package) U.S. Census API query.
GoalWhat I want is, for ages 20-24 in this example, a data frame that extracts the ages from label entries like "22 to 24 years"
:
ANSWER
Answered 2022-Feb-04 at 21:55I tend to do this in two steps. The first step specifies some characteristic in a metadata file. The second step applies the metadata to the problem.
It looks like you'll need to approximate some, because the levels don't cleanly fit your boundaries. For example, "15 to 19 years old" straddles 18.
(To keep things simpler, I'm assuming you'll never want to keep the "20 to 24 years" level, but exclude the "20 to 24 years old" level.
QUESTION
I am attempting to outline a specific grouping of census tracts over entire US states.
This is the code I am attempting to run:
...ANSWER
Answered 2022-Feb-04 at 17:21Your arlington.test
object seems to be in EPSG:4269; you attempted to override it to WGS 84 via sf::st_set_crs(4326)
. Are you certain you did not mean sf::st_transform(4326)
?
The set crs is best reserved for cases you are certain the CRS is malformed / incorrect (it can happen when the *.prj
gets lost from your *.shp
shapefile). This is not a typical use case for {tidycensus}
data.
To change projection from one known CRS to another sf::st_transform()
works the best.
QUESTION
I am trying to download the average population for AZ counties using tidycensus
, using the code below. How can I download population data for a time series period from 2000-2019 (interpolating for years that do not have decennial census or acs data)
ANSWER
Answered 2021-Nov-10 at 15:52You can use the tidycensus function, get_estimates()
to get population estimates by county for each year beginning in 2010.
QUESTION
I am working with tidycensus
and segregation
to do an analysis.
To create my data, I am running this:
...ANSWER
Answered 2021-Sep-03 at 02:30Based on the code showed, the split
is a base R
function which can extract the column with $
or [[
or use with
. As 'Inglewood' is not showed in the dput
data, we use "Roseville"
QUESTION
I am trying to calculate the population under 20 by race for each county in MN using the American Community Survey in R. Using Tidycensus I am aware this can be done using the B01001H variables for each race and age group in R. However I would need to aggregate all the variables for those under 20 for each racial group. According to this webpage (https://www.census.gov/content/dam/Census/library/publications/2018/acs/acs_general_handbook_2018_ch08.pdf) while aggregating the estimates is merely the sum of each of the subgroup values, aggregating the margin of error requires I calculate this formula:
...ANSWER
Answered 2021-Jun-01 at 03:36Instead of summarise
and join you can use mutate
to add new columns in the data directly.
QUESTION
I have been working with some tidycensus data for an assignment and have gotten to the point where trying to generate a smooth line graph isn't plotting my dataset.
My current code is:
...ANSWER
Answered 2021-Feb-07 at 00:54So I figured out what I was doing wrong! Apparently, my dataset listed for the graph generation was one that was calculating averages for other problems on the assignment. It consisted of single averaged observations.
So the fix to this was to go back to my originally cleaned dataset and change the parameters to reflect the old variables before averages were taken.
QUESTION
I am trying to create a treatment dummy for the states whose 1970 legal1820
is different from their legal1820
in 1979. So I need the proper syntax for somethihng like this treat = ifelse((legal1820 when (year == 1970)) != (legal1820 when (year == 1979)) , 1,0)
this is the data I am using
...ANSWER
Answered 2020-Nov-28 at 14:29Is this what you are looking for?
QUESTION
Is it possible to use ggrough
(https://xvrdm.github.io/ggrough/index.html) to shade shapes created by geom_sf
(preferred) or potentially geom_polygon
? See this question for a prior question that gives the look of the plot I have in mind and the accompanying answer by Z.Lin that modifies the package to make it compatible with the current version of ggplot2
: Unable to replicate this ggplot2 plot.
Here is a MWE of a map created using geom_sf
that I would like to shade (each individual county) using ggrough
:
ANSWER
Answered 2020-Sep-26 at 12:32library(magrittr)
library(ggplot2)
library(ggrough)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install tidycensus
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page