Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a population dataset #95

Merged
merged 11 commits into from
Oct 18, 2024
65 changes: 65 additions & 0 deletions R/ons_uk_population_2023.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#' ONS Mid-2023 Population Estimate for UK
#'
#' ONS Population Estimates for Mid-year 2023
#' National and subnational mid-year population estimates for the UK and its
#' constituent countries by administrative area, age and sex (including
#' components of population change, median age and population density).
#'
#' Data sourced from
#' \href{https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/datasets/populationestimatesforukenglandandwalesscotlandandnorthernireland}
#'
#' @docType data
#'
#' @keywords datasets ons population
#'
#' @format Tibble with six columns
#' \describe{
#' \item{sex}{male or female}
#' \item{Code}{The country/geography code}
#' \href{Name}{country of the UK}
#' \item{Geography}{Country}
#' \item{age}{year of age}
#' \item{count}{the number of people in this group}
#' }
#'
#' @source \href{https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/datasets/populationestimatesforukenglandandwalesscotlandandnorthernireland}{ONS Estimates of the population for the UK, England, Wales, Scotland, and Northern Ireland}
#'
#' @usage data(ons_uk_population_2023)
#'
#' @examples
#' data(ons_uk_population_2023)
#'
#' library(readxl)
#' library(tidyverse)
#' library(tidyr)

#' Load the data in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' Load the data in
#' # Load the data in

that line needs to be forced to be a comment: it's trying to run Load the data in as an R command

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, I would remove and change the entire example here:

  • the example is meant to be about using the data, not how to generate it
  • the example includes a path to a file on your local computer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thats all been fixed just now anyway, but still failing !

#' population_data_2023_f <- read_excel(
#' "C:/Users/jacqueline.grout/Downloads/mye23tablesuk.xlsx",
#' sheet="MYE2 - Females",
#' skip = 7)

#' population_data_2023_m <- read_excel(
#' "C:/Users/jacqueline.grout/Downloads/mye23tablesuk.xlsx",
#' sheet="MYE2 - Males",
#' skip = 7)


#' pivot longer
#' population_data_2023_f <- population_data_2023_f |>
#' select(!`All ages`) |>
#' pivot_longer(`0`:`90+`, names_to = "age", values_to = "count")

#' population_data_2023_m <- population_data_2023_m |>
#' select(!`All ages`) |>
#' pivot_longer(`0`:`90+`, names_to = "age", values_to = "count")

#' population_data_combined <- bind_rows(
#' females = population_data_2023_f,
#' males = population_data_2023_m,
#' .id = "sex"
#' )
#'
#'
#'
"ons_uk_population_2023"
Binary file added data/ons_uk_population_2023.rda
Binary file not shown.
67 changes: 67 additions & 0 deletions man/ons_uk_population_2023.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading