<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://acsdatacommunity.prb.org/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Calculating percentage of individuals in a census tract with high school diploma or equivalent using tidycensus</title><link>https://acsdatacommunity.prb.org/discussion-forum/f/forum/717/calculating-percentage-of-individuals-in-a-census-tract-with-high-school-diploma-or-equivalent-using-tidycensus</link><description> Hello everyone, 
 New here! 
 I am analyzing ACS data for the state of Kentucky. I am trying to figure out how to calculate percentage of individuals in a census tract who have graduated high school using tidycensus. I realize the educational attainment</description><dc:language>en-US</dc:language><generator>Telligent Community 11</generator><item><title>RE: Calculating percentage of individuals in a census tract with high school diploma or equivalent using tidycensus</title><link>https://acsdatacommunity.prb.org/thread/1749?ContentTypeID=1</link><pubDate>Thu, 08 Apr 2021 00:55:05 GMT</pubDate><guid isPermaLink="false">3e86467a-1916-4e54-a922-55a4945229ec:48106497-bf37-415d-b92a-bc9f3e52adb5</guid><dc:creator>bhargaab</dc:creator><description>&lt;p&gt;Thank you sir! I wrote some really ridiculous code using the wrong table that got me the wrong results... this is super helpful!&lt;/p&gt;
&lt;p&gt;- A&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calculating percentage of individuals in a census tract with high school diploma or equivalent using tidycensus</title><link>https://acsdatacommunity.prb.org/thread/1748?ContentTypeID=1</link><pubDate>Thu, 08 Apr 2021 00:05:17 GMT</pubDate><guid isPermaLink="false">3e86467a-1916-4e54-a922-55a4945229ec:01c7249c-09e2-40f3-bcdb-d91f02efd029</guid><dc:creator>Matt Herman</dc:creator><description>&lt;p&gt;I think the table you may be looking for is &lt;a href="https://censusreporter.org/tables/B15003/"&gt;B15003&lt;/a&gt;, which contains educational attainment for the population 25 and older. Using tidycensus, you can specify the variables from that table B15003_017 through B15003_25 that represent the population with a HS diploma and above. To calculate the percentage, you also will need to grab the total population 25 and older to use as the denominator, which is B15003_001.&lt;/p&gt;
&lt;p&gt;This code should get you there - also note the margin of error calculations are included below as well.&lt;/p&gt;
&lt;pre&gt;library(tidycensus)&lt;br /&gt;library(dplyr)
&lt;br /&gt;ky_ed &amp;lt;- get_acs(&lt;br /&gt; geography = &amp;quot;tract&amp;quot;,&lt;br /&gt; variables = paste0(&amp;quot;B15003_0&amp;quot;, 17:25),  # hs diploma and above variables&lt;br /&gt; summary_var = &amp;quot;B15003_001&amp;quot;,             # pop 25 years and older - denominator&lt;br /&gt;&amp;nbsp;state = &amp;quot;KY&amp;quot;&lt;br /&gt; )&lt;br /&gt;&lt;br /&gt;ky_ed %&amp;gt;% &lt;br /&gt; group_by(GEOID, NAME) %&amp;gt;% &lt;br /&gt; summarize(&lt;br /&gt;   n_hs_above = sum(estimate),&lt;br /&gt;   n_hs_above_moe = moe_sum(moe, estimate),&lt;br /&gt;   n_pop_over_25 = summary_est[1],&lt;br /&gt;   n_pop_over_25_moe = summary_moe[1]&lt;br /&gt; ) %&amp;gt;% &lt;br /&gt; ungroup() %&amp;gt;% &lt;br /&gt; mutate(&lt;br /&gt;   pct_hs_above = n_hs_above / n_pop_over_25,&lt;br /&gt;   pct_hs_above_moe = moe_prop(n_pop_over_25, n_pop_over_25,&lt;br /&gt;                               n_hs_above_moe, n_pop_over_25_moe)&lt;br /&gt; )&lt;br /&gt;&lt;br /&gt;#&amp;gt; # A tibble: 1,115 x 8&lt;br /&gt;#&amp;gt; GEOID NAME n_hs_above n_hs_above_moe n_pop_over_25 n_pop_over_25_m~&lt;br /&gt;#&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;&lt;br /&gt;#&amp;gt; 1 210019~ Census Trac~ 958 174. 1210 176&lt;br /&gt;#&amp;gt; 2 210019~ Census Trac~ 1255 204. 1465 156&lt;br /&gt;#&amp;gt; 3 210019~ Census Trac~ 1750 283. 2460 272&lt;br /&gt;#&amp;gt; 4 210019~ Census Trac~ 2395 335. 3107 268&lt;br /&gt;#&amp;gt; 5 210019~ Census Trac~ 1987 295. 2323 334&lt;br /&gt;#&amp;gt; 6 210019~ Census Trac~ 1275 196. 1537 191&lt;br /&gt;#&amp;gt; 7 210019~ Census Trac~ 882 176. 1097 178&lt;br /&gt;#&amp;gt; 8 210039~ Census Trac~ 2039 271. 2358 215&lt;br /&gt;#&amp;gt; 9 210039~ Census Trac~ 1521 212. 1850 211&lt;br /&gt;#&amp;gt; 10 210039~ Census Trac~ 2861 448. 3558 302&lt;br /&gt;#&amp;gt; # ... with 1,105 more rows, and 2 more variables: pct_hs_above &amp;lt;dbl&amp;gt;,&lt;br /&gt;#&amp;gt; # pct_hs_above_moe &amp;lt;dbl&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>