diff --git a/DESCRIPTION b/DESCRIPTION index 3572d76..5db376d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,6 +5,8 @@ Version: 0.0.2 Authors@R: c( person("Zoƫ", "Turner", email = "zoe.turner3@nhs.net", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1033-9158")), + person("Francis", "Barton", email = "fbarton@alwaysdata.net", + role = c("aut"), comment = c(ORCID = "0000-0002-5650-1176")), person("Milan", "Wiedemann", role = c("aut"), comment = c(ORCID = "0000-0003-1991-282X")), person("Chris", "Beeley", role = c("aut"), @@ -18,23 +20,22 @@ LazyData: true Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 Imports: - cli, dplyr, - ggplot2, - jsonlite, + httr2, + janitor, magrittr, NHSRpostcodetools, - patchwork, - tidyr + purrr, + rlang, + stringr, + tibble Depends: R (>= 2.10) Suggests: httptest2, knitr, - purrr, rmarkdown, - testthat (>= 3.0.0), - tibble + testthat (>= 3.0.0) Remotes: nhs-r-community/NHSRpostcodetools VignetteBuilder: knitr Config/testthat/edition: 3 diff --git a/NHSRpopulation.Rproj b/NHSRpopulation.Rproj deleted file mode 100644 index 270314b..0000000 --- a/NHSRpopulation.Rproj +++ /dev/null @@ -1,21 +0,0 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: pdfLaTeX - -AutoAppendNewline: Yes -StripTrailingWhitespace: Yes - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace diff --git a/R/get_data.R b/R/get_data.R index e56053b..aa0f4f8 100644 --- a/R/get_data.R +++ b/R/get_data.R @@ -35,6 +35,9 @@ get_data <- function(data, url_type <- match.arg(url_type) req <- api_url() column <- rlang::as_string(column) + value <- NULL + lsoa11cd <- NULL + lsoa_code <- NULL # Check there is corresponding type data somewhere in data frame # Use this to allow for other column names to be used in later code @@ -68,7 +71,7 @@ get_data <- function(data, ## Generate specific text for the url if (is.atomic(data) && is_postcode_check == 0 && - is_lsoa_check > 0) { + is_lsoa_check > 0) { text <- paste0( "LSOA11CD IN ('", paste(data, @@ -76,9 +79,7 @@ get_data <- function(data, ), "')" ) } else if (is.data.frame(data) && is_postcode_check == 0 && - is_lsoa_check > 0) { - # text <- "1=1" # get all rows (no filter) Takes a while to run - + is_lsoa_check > 0) { text <- paste0( "LSOA11CD IN ('", paste(data[[column]], @@ -112,7 +113,7 @@ get_data <- function(data, ## IMD data if (is_postcode_check == 0 && is_lsoa_check > 0 && - is.data.frame(data)) { + is.data.frame(data)) { data_out <- imd_api( text = text, req = req @@ -146,9 +147,10 @@ get_data <- function(data, ) pc_data |> - dplyr::left_join(data_out, - dplyr::join_by(lsoa_code == lsoa11cd)) - + dplyr::left_join( + data_out, + dplyr::join_by(lsoa_code == lsoa11cd) + ) } else if (exists("pc_data") && url_type == "postcode") { pc_data } else { diff --git a/R/zzz.R b/R/zzz.R deleted file mode 100644 index f2d4646..0000000 --- a/R/zzz.R +++ /dev/null @@ -1,14 +0,0 @@ -.onAttach <- function(libname, pkgname) { - version <- read.dcf( - file = system.file("DESCRIPTION", - package = pkgname - ), - fields = "Version" - ) - - cli::cli_h1(paste0("This is ", pkgname, " ", version)) - cli::cli_alert_info(paste0("Please report any issues or ideas at:")) - cli::cli_alert_info( - "https://github.com/nhs-r-community/NHSRpopulation/issues" - ) -} diff --git a/_pkgdown.yml b/_pkgdown.yml index a10c9bc..b0fcaab 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -10,4 +10,10 @@ navbar: right: - search - reference + - github +authors: + footer: + roles: [aut] + sidebar: + roles: [aut] diff --git a/tests/testthat/test-get_data.R b/tests/testthat/test-get_data.R index 9ba7b00..12382e8 100644 --- a/tests/testthat/test-get_data.R +++ b/tests/testthat/test-get_data.R @@ -4,22 +4,6 @@ postcodes <- c("HD1 2UT", "HD1 2UU", "HD1 2UV") imd <- c("E01011107", "E01011229", "E01002") -# # Taken from -# # www.gov.uk/government/statistics/english-indices-of-deprivation-2019 -# -# postcodes_from_each_decile <- c( -# "E01000002", -# "E01000001", -# "E01000117", -# "E01000119", -# "E01000069", -# "E01000070", -# "E01000066", -# "E01000005", -# "E01000008", -# "E01000048" -# ) -# ## Data frames test_df1 <- dplyr::tibble( @@ -138,69 +122,6 @@ test_that("Returns data with different column names - imd", { n_col_imd ) }) -# }) - -# httptest2::with_mock_dir("postcode_message", { -# test_that("Returns message there is no postcode data for data frame", { -# testthat::expect_error( -# get_data(missing_df1, "postcode"), -# paste( -# "There isn't any postcode data in this data frame to", -# "connect to the Postcode API." -# ) -# ) -# }) -# -# test_that("Returns message there is no postcode data for vector", { -# testthat::expect_error( -# get_data(missing_vector, "postcode"), -# paste( -# "There isn't any postcode data in this vector to", -# "connect to the Postcode API." -# ) -# ) -# }) - -# test_that("Returns message there is no column called postcode - data frame", { -# testthat::expect_error( -# get_data(no_postcode_colm), -# paste0( -# "There isn't a column called `postcode` in this data frame." -# ) -# ) -# }) -# }) - -# httptest2::with_mock_dir("imd_message", { -# test_that("Returns message there is no imd data for data frame", { -# testthat::expect_error( -# get_data(missing_df1, "imd"), -# paste( -# "There doesn't appear to be any data in this data frame", -# "to connect to the IMD API." -# ) -# ) -# }) - -# test_that("Returns message there is no imd data for vector", { -# testthat::expect_error( -# get_data(missing_vector, "imd"), -# paste( -# "There doesn't appear to be any data in this data frame", -# "to connect to the IMD API." -# ) -# ) -# }) -# -# test_that("Returns message there is no column called lsoa11 - data frame", { -# testthat::expect_error( -# get_data(no_postcode_colm, "imd"), -# paste0( -# "There isn't a column called `lsoa11` in this data frame." -# ) -# ) -# }) -# }) httptest2::with_mock_dir("imd", { test_that("Returns url_type = 'imd'", { diff --git a/vignettes/articles/Getting-Started.Rmd b/vignettes/articles/Getting-Started.Rmd deleted file mode 100644 index f5f7f04..0000000 --- a/vignettes/articles/Getting-Started.Rmd +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "Getting Started" ---- - -```{r, include = FALSE} -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" -) -``` - -```{r setup} -library(NHSRpopulation) -```