<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/nomisr-access-nomis-uk-labour-market-data/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://ropensci.org/technotes/2018/05/08/nomisr/"> rOpenSci - open tools for open science</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I’m excited to announce a new package for accessing official statistics from the UK. <a rel="nofollow" href="https://github.com/ropensci/nomisr" target="_blank"><code>nomisr</code></a> is the R client for the <a rel="nofollow" href="https://www.nomisweb.co.uk/" target="_blank">Nomis</a> database. Nomis is run by Durham University on behalf of the UK’s Office for National Statistics (ONS), and contains over a thousand datasets, primarily on the UK labour market, census data, benefit spending and general economic activity. Registration is optional, although registration and the use of an API key allows for larger queries without the risk of being timed out or rate limited by the API.</p>
<p>Most data in Nomis is arranged in statistical geographies – ranging from the whole of the UK to small output areas, making <code>nomisr</code> a useful tool for map-making and social geography. The example below shows how to retrieve the latest data on the number of Job Seekers Allowance claimants in each parliamentary constitutency, and maps them onto a cartogram from the <a rel="nofollow" href="https://cran.r-project.org/package=parlitools" target="_blank"><code>parlitools</code></a> package, using the <a rel="nofollow" href="http://github.com/tidyverse/ggplot2/" target="_blank">development version of <code>ggplot2</code></a></p>
<pre><code>library(nomisr)
library(dplyr)
library(parlitools)
library(viridis)
#devtools::install_github(&quot;tidyverse/ggplot2/&quot;)
library(ggplot2)
library(sf)

jsa_constits &lt;- nomis_get_data(id = &quot;NM_1_1&quot;, time = &quot;latest&quot;, 
                               measures = 20100, sex = 7,
                               geography = &quot;TYPE460&quot;, 
                               additional_queries = &quot;&amp;item=1&quot;)

jsa_constits$GEOGRAPHY_NAME &lt;- gsub(&quot;Na h-Eileanan An Iar&quot;, 
                                    &quot;Na h-Eileanan an Iar&quot;, 
                                    jsa_constits$GEOGRAPHY_NAME)

jsa_constits$GEOGRAPHY_NAME &lt;- gsub(&quot;St &quot;, &quot;St. &quot;, jsa_constits$GEOGRAPHY_NAME)

west_hex_map &lt;- parlitools::west_hex_map %>% 
  inner_join(jsa_constits, by = c(&quot;constituency_name&quot; = &quot;GEOGRAPHY_NAME&quot;))

west_hex_map$OBS_VALUE &lt;- as.numeric(west_hex_map$OBS_VALUE)

p1 &lt;- ggplot(west_hex_map) + geom_sf(aes(geometry = geometry, 
                             fill = OBS_VALUE), color = &quot;black&quot;) +
  coord_sf(datum = sf::st_crs(west_hex_map$geometry)) +
  scale_fill_viridis(option = &quot;E&quot;) + 
  labs(title = &quot;JSA Claimants per Constituency&quot;, fill = &quot;JSA Claimants&quot;)

p1
</code></pre>
<p><img alt="map-chunk-1" src="https://i2.wp.com/i.imgur.com/x0e4ZXf.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p><code>nomisr</code> was developed to make using UK labour market statistics faster, easier and more replicable. I’ve used it to speed up research for policy and issue briefings in my day job</p>
<h2>To do</h2>
<p>The <code>nomisr</code> package covers most of the features available on Nomis, with the exception of a grouping function that can easily be replicated in R using tools like <a rel="nofollow" href="https://cran.r-project.org/package=dplyr" target="_blank"><code>dplyr</code></a> and that will likely be incorporated into a future release, as will an optional parameter to change variable names to snake_case instead of the API’s default all caps response. Long term development is focused on making the package more user-friendly for people with less familiarity with Nomis data and the API structure.</p>
<h3>Package review</h3>
<p>Thank you to reviewers <a rel="nofollow" href="https://github.com/pegeler" target="_blank">Paul Egeler</a> and <a rel="nofollow" href="https://github.com/cderv" target="_blank">Christophe Dervieux</a> for their incredibly helpful comments and suggestions, and for <a rel="nofollow" href="https://github.com/karthik" target="_blank">Karthik Ram</a>’s editorial supervision. <code>nomisr</code> is a much better package than would otherwise have been the case as a result of their efforts.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://ropensci.org/technotes/2018/05/08/nomisr/"> rOpenSci - open tools for open science</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/nUhtG6Xv05g" height="1"></a></div>