/SmarterScotland

R package facilitating sourcing data from https://statistics.gov.scot.

Primary LanguageRGNU General Public License v3.0GPL-3.0

README

SmarterScotland

Lifecycle: experimental Build Status codecov Build status license develVersion CRAN status

Overview

The SmarterScotland package provides a convenient interface for sourcing and interrogating data available through the statistics.gov.scot.

Example

# Data
library(SmarterScotland)
# Visuals and data manipulation
suppressPackageStartupMessages(library(tidyverse))
# Data sourcing
dta_Glasgow_Crime <- get_geography_data(data_set = "recorded-crime",
                                        geography = "Glasgow City",
                                        measure = "count",
                                        pre_process_results = TRUE)
# Summary chart
dta_Glasgow_Crime %>% 
  filter(crime_or_offence == "all-crimes") %>%
  select(count, reference_period) %>% 
  arrange(desc(reference_period)) %>% 
  ggplot(aes(x = reference_period, y = count, group = 1)) +
  geom_line() +
  labs(x = "Reference Period",
       y = "Count",
       title = "Total Crime in Glasgow City") +
  scale_y_continuous(labels = function(x) format(x, big.mark = ",", scientific = FALSE)) +
  theme_light() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Installation

if (isFALSE("remotes" %in% rownames(installed.packages()))) {
  install.packages("remotes")
}
remotes::install_github(repo = "konradzdeb/SmarterScotland", build_vignettes = TRUE,
                        dependencies = TRUE)

Similar projects