<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/is-gina-really-about-to-die/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.nathanchaney.com/2018/07/13/is-gina-really-about-to-die/"> R – Nathan Chaney</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<h3>Introduction</h3>
<p>During a recent negotiation of an informed consent form for use in a clinical trial, the opposing lawyer and I skirmished over the applicability of the Genetic Information Nondiscrimination Act of 2008, commonly known as GINA. Specifically, the opposing lawyer thought that <a rel="nofollow" href="https://www.hhs.gov/ohrp/regulations-and-policy/guidance/guidance-on-genetic-information-nondiscrimination-act/index.html" target="_blank">guidance issued by the U.S. Office for Human Research Protections in 2009</a> was now outdated, in part because enforcement efforts were erratic. The argument was primarily driven by policy, rather than data.</p>
<p>Being a data-driven guy, I wanted to see whether the data supported the argument advanced by the other lawyer. Fortunately, the U.S. Equal Employment Opportunity Commission (EEOC), which is responsible for administering GINA complaints, maintains <a rel="nofollow" href="https://www.eeoc.gov/laws/types/genetic.cfm" target="_blank">statistics regarding GINA claims and resolutions</a>. I’m not great at making sense of numbers in a table, so I thought this presented the perfect opportunity to rvest some data!</p>
<pre><code>libraries &lt;- c(&quot;tidyverse&quot;, &quot;rvest&quot;, &quot;magrittr&quot;)
lapply(libraries, require, character.only = TRUE)
</code></pre>
</div>
<div>
<h3>Data Scraping</h3>
<p>In standard rvest fashion, we’ll read a url, extract the table containing the GINA enforcement statistics, and then do some data cleaning. Once we read the table and gather all of the annual results into key/pair of year/value, we get the following results:</p>
<pre><code>url &lt;- &quot;https://www.eeoc.gov/eeoc/statistics/enforcement/genetic.cfm&quot;

GINA.resolutions &lt;- read_html(url) %>%
  html_nodes(&quot;table&quot;) %>% 
  extract2(1) %>%
  html_table(trim = TRUE, fill = TRUE, header = TRUE) 

names(GINA.resolutions)[1] &lt;- &quot;metric&quot; # Top left table cell is blank, will throw errors
names(GINA.resolutions) &lt;- gsub(&quot;FY (.+)&quot;, &quot;\\1&quot;, names(GINA.resolutions)) # Remove FY from year so we can convert to numeric

GINA.resolutions &lt;- GINA.resolutions %>%
  filter(! metric == &quot;&quot;) %>% # Remove percentage rows
  filter(! metric == &quot;Resolutions By Type&quot;) %>% # Remove blank line
  gather(year, value, 2:9) %>% # short and wide data to tall and skinny
  mutate(
    year = as.integer(year),
    value = gsub(&quot;[\\$\\%]&quot;, &quot;&quot;, value)
  ) %>%
  mutate(
    value = as.numeric(value)
  ) %>%
  as.tibble()

GINA.resolutions</code></pre>
<pre><code>## # A tibble: 88 x 3
##    metric                      year value
##    </code></pre></div>