diff --git a/DESCRIPTION b/DESCRIPTION index f5466c3..33e99da 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,7 +30,7 @@ Imports: utils, rsdmx, rlang -RoxygenNote: 6.1.1 +RoxygenNote: 7.0.2 Suggests: knitr, rmarkdown, diff --git a/R/api-key.R b/R/api-key.R index 33b70cd..adca18c 100644 --- a/R/api-key.R +++ b/R/api-key.R @@ -13,7 +13,7 @@ #' reload the API key or would like to manually enter one in, this function #' may be used. #' -#' @details You can sign up for an API key +#' @details You can sign up for an API key #' [here](https://www.nomisweb.co.uk/myaccount/userjoin.asp). #' #' @param check_env If TRUE, will check the environment variable diff --git a/R/codelist.R b/R/codelist.R index 535f7ba..d788a18 100644 --- a/R/codelist.R +++ b/R/codelist.R @@ -24,7 +24,8 @@ #' @seealso [nomis_get_metadata()] #' @seealso [nomis_overview()] #' -#' @examples \donttest{ +#' @examples +#' \donttest{ #' x <- nomis_codelist("NM_1_1", "item") #' #' @@ -34,7 +35,7 @@ #' #' z <- nomis_codelist("NM_161_1", "cause_of_death") #' } - +#' nomis_codelist <- function(id, concept, search = NULL) { if (missing(id)) { stop("id must be specified", call. = FALSE) diff --git a/R/content_type.R b/R/content_type.R index 9d84cb0..e2b51ae 100644 --- a/R/content_type.R +++ b/R/content_type.R @@ -18,7 +18,8 @@ #' @seealso [nomis_search()] #' @seealso [nomis_data_info()] #' -#' @examples \donttest{ +#' @examples +#' \donttest{ #' a <- nomis_content_type("sources") #' #' tibble::glimpse(a) @@ -27,8 +28,7 @@ #' #' tibble::glimpse(b) #' } - - +#' nomis_content_type <- function(content_type, id = NULL) { if (missing(content_type)) { stop("content_type must be specified", call. = FALSE) diff --git a/R/data_download.R b/R/data_download.R index 973e631..4a305db 100644 --- a/R/data_download.R +++ b/R/data_download.R @@ -29,7 +29,7 @@ #' `date = c("first", "latest")` will return only the earliest and latest #' data published. #' -#' @param id A string containing the ID of the dataset to retrieve, +#' @param id A string containing the ID of the dataset to retrieve, #' in `"nm_***_*"` format. The `id` parameter is not case sensitive. #' #' @param time Parameter for selecting dates and date ranges. Accepts either a @@ -37,8 +37,8 @@ #' date values, There are two styles of values that can be used to query time. #' #' The first is one or two of `"latest"` (returns the latest available -#' data), `"previous"` (the date prior to `"latest"`), `"prevyear"` -#' (the date one year prior to `"latest"`) or `"first"` +#' data), `"previous"` (the date prior to `"latest"`), `"prevyear"` +#' (the date one year prior to `"latest"`) or `"first"` #' (the oldest available data for the dataset). #' #' The second style is to use or a specific date or multiple dates, in the @@ -56,7 +56,7 @@ #' returned, but there is no limit to the number of data values. For example, #' `date=c("latest, latestMINUS3, latestMINUS6")` will return the latest #' data, data from three months prior to the latest data and six months prior -#' to the latest data. There are two styles of values that can be used to +#' to the latest data. There are two styles of values that can be used to #' query time. #' #' The first is one or more of `"latest"` (returns the latest available @@ -92,17 +92,17 @@ #' all available sex/gender data. #' #' There are two different codings used for sex, depending on the dataset. For -#' datasets using `"SEX"`, `7` will return results for males and females, `6` -#' only females and `5` only males. Defaults to `NULL`, equivalent to -#' `c(5,6,7)` for datasets where sex is an option. For datasets using -#' `"C_SEX"`, `0` will return results for males and females, `1` only males -#' and `2` only females. Some datasets use `"GENDER"` with the same values -#' as `"SEX"`, which works with both `sex = ` and `gender = ` +#' datasets using `"SEX"`, `7` will return results for males and females, `6` +#' only females and `5` only males. Defaults to `NULL`, equivalent to +#' `c(5,6,7)` for datasets where sex is an option. For datasets using +#' `"C_SEX"`, `0` will return results for males and females, `1` only males +#' and `2` only females. Some datasets use `"GENDER"` with the same values +#' as `"SEX"`, which works with both `sex = ` and `gender = ` #' as a dot parameter. #' #' @param additional_queries Any other additional queries to pass to the API. #' See \url{https://www.nomisweb.co.uk/api/v01/help} for instructions on -#' query structure. Defaults to `NULL`. Deprecated in package versions greater +#' query structure. Defaults to `NULL`. Deprecated in package versions greater #' than 0.2.0 and will eventually be removed in a future version. #' #' @param exclude_missing If `TRUE`, excludes all missing values. @@ -119,11 +119,11 @@ #' @param tidy_style The style to convert variable names to, if #' `tidy = TRUE`. Accepts one of `"snake_case"`, `"camelCase"` #' and `"period.case"`. Defaults to `"snake_case"`. -#' -#' @param query_id Results can be labelled as belonging to a certain query -#' made to the API. `query_id` accepts any value as a string, and will -#' be included in every row of the tibble returned by `nomis_get_data` -#' in a column labelled "QUERY_ID" in the default SCREAMING_SNAKE_CASE +#' +#' @param query_id Results can be labelled as belonging to a certain query +#' made to the API. `query_id` accepts any value as a string, and will +#' be included in every row of the tibble returned by `nomis_get_data` +#' in a column labelled "QUERY_ID" in the default SCREAMING_SNAKE_CASE #' used by the API. Defaults to `NULL`. #' #' @param ... Use to pass any other parameters to the API. Useful for passing @@ -135,66 +135,83 @@ #' Parameters are not case sensitive. Note that R using partial matching for #' function variables, and so passing a parameter with the same opening #' characters as one of the above-named parameters can cause an error unless -#' the value of the named parameter is specified, including as `NULL`. +#' the value of the named parameter is specified, including as `NULL`. #' See example below: #' -#' @return A tibble containing the selected dataset. By default, all tibble +#' @return A tibble containing the selected dataset. By default, all tibble #' columns except for the `"OBS_VALUE"` column are parsed as characters. #' @export #' @seealso [nomis_data_info()] #' @seealso [nomis_get_metadata()] #' @seealso [nomis_codelist()] #' @seealso [nomis_overview()] -#' @examples \donttest{ +#' @examples +#' \donttest{ #' #' # Return data on Jobseekers Allowance for each country in the UK -#' jobseekers_country <- nomis_get_data(id = "NM_1_1", time = "latest", -#' geography = "TYPE499", -#' measures = c(20100, 20201), sex = 5) +#' jobseekers_country <- nomis_get_data( +#' id = "NM_1_1", time = "latest", +#' geography = "TYPE499", +#' measures = c(20100, 20201), sex = 5 +#' ) #' #' tibble::glimpse(jobseekers_country) #' #' # Return data on Jobseekers Allowance for Wigan -#' jobseekers_wigan <- nomis_get_data(id = "NM_1_1", time = "latest", -#' geography = "1879048226", -#' measures = c(20100, 20201), sex = "5") +#' jobseekers_wigan <- nomis_get_data( +#' id = "NM_1_1", time = "latest", +#' geography = "1879048226", +#' measures = c(20100, 20201), sex = "5" +#' ) #' #' tibble::glimpse(jobseekers_wigan) #' #' # annual population survey - regional - employment by occupation -#' emp_by_occupation <- nomis_get_data(id = "NM_168_1", time = "latest", -#' geography = "2013265925", sex = "0", -#' select = c("geography_code", -#' "C_OCCPUK11H_0_NAME", "obs_vAlUE")) +#' emp_by_occupation <- nomis_get_data( +#' id = "NM_168_1", time = "latest", +#' geography = "2013265925", sex = "0", +#' select = c( +#' "geography_code", +#' "C_OCCPUK11H_0_NAME", "obs_vAlUE" +#' ) +#' ) #' #' tibble::glimpse(emp_by_occupation) #' -#' # Deaths in 2016 and 2015 by three specified causes, +#' # Deaths in 2016 and 2015 by three specified causes, #' # identified with nomis_get_metadata() -#' death <- nomis_get_data("NM_161_1", date = c("2016","2015"), -#' geography = "TYPE480", -#' cause_of_death = c(10300, 102088, 270)) +#' death <- nomis_get_data("NM_161_1", +#' date = c("2016", "2015"), +#' geography = "TYPE480", +#' cause_of_death = c(10300, 102088, 270) +#' ) #' #' tibble::glimpse(death) #' #' # All causes of death in London in 2016 -#' london_death <- nomis_get_data("NM_161_1", date = c("2016"), -#' geography = "2013265927", sex = 1, age = 0) +#' london_death <- nomis_get_data("NM_161_1", +#' date = c("2016"), +#' geography = "2013265927", sex = 1, age = 0 +#' ) #' #' tibble::glimpse(london_death) #' } #' \dontrun{ -#' # Results in an error because `measure` is mistaken for `measures` -#' mort_data1 <- nomis_get_data(id = "NM_161_1", date = "2016", -#' geography = "TYPE464", sex = 0, cause_of_death = "10381", -#' age = 0, measure = 6) -#' -#' # Does not error because `measures` is specified -#' mort_data2 <- nomis_get_data(id = "NM_161_1", date = "2016", -#' geography = "TYPE464", sex = 0, measures = NULL, -#' cause_of_death = "10381", age = 0, measure = 6) +#' # Results in an error because `measure` is mistaken for `measures` +#' mort_data1 <- nomis_get_data( +#' id = "NM_161_1", date = "2016", +#' geography = "TYPE464", sex = 0, cause_of_death = "10381", +#' age = 0, measure = 6 +#' ) +#' +#' # Does not error because `measures` is specified +#' mort_data2 <- nomis_get_data( +#' id = "NM_161_1", date = "2016", +#' geography = "TYPE464", sex = 0, measures = NULL, +#' cause_of_death = "10381", age = 0, measure = 6 +#' ) #' } - +#' nomis_get_data <- function(id, time = NULL, date = NULL, geography = NULL, sex = NULL, measures = NULL, additional_queries = NULL, exclude_missing = FALSE, @@ -270,7 +287,7 @@ nomis_get_data <- function(id, time = NULL, date = NULL, geography = NULL, ), "" ) - + query_id <- ifelse(!is.null(query_id), paste0("&queryid=", query_id), "") dots <- rlang::list2(...) ## eval the dots diff --git a/R/dataset_info.R b/R/dataset_info.R index a153cf6..641f1d9 100644 --- a/R/dataset_info.R +++ b/R/dataset_info.R @@ -14,7 +14,8 @@ #' @seealso [nomis_overview()] #' @seealso [nomis_codelist()] #' -#' @examples \donttest{ +#' @examples +#' \donttest{ #' #' # Get info on all datasets #' x <- nomis_data_info() @@ -22,12 +23,11 @@ #' tibble::glimpse(x) #' #' # Get info on a particular dataset -#' y <- nomis_data_info('NM_1658_1') +#' y <- nomis_data_info("NM_1658_1") #' #' tibble::glimpse(y) -#' #' } - +#' nomis_data_info <- function(id) { if (missing(id)) { data_info_query <- "def.sdmx.json" diff --git a/R/metadata.R b/R/metadata.R index 867164b..61a7cbd 100644 --- a/R/metadata.R +++ b/R/metadata.R @@ -39,34 +39,35 @@ #' [nomis_get_data()]. #' @export #' -#' @examples \donttest{ -#' a <- nomis_get_metadata('NM_1_1') +#' @examples +#' \donttest{ +#' a <- nomis_get_metadata("NM_1_1") #' #' tibble::glimpse(a) #' -#' b <- nomis_get_metadata('NM_1_1', 'geography') +#' b <- nomis_get_metadata("NM_1_1", "geography") #' #' tibble::glimpse(b) #' #' # returns all types of geography -#' c <- nomis_get_metadata('NM_1_1', 'geography', 'TYPE') +#' c <- nomis_get_metadata("NM_1_1", "geography", "TYPE") #' #' tibble::glimpse(c) #' #' # returns geography types available within Wigan -#' d <- nomis_get_metadata('NM_1_1', 'geography', '1879048226') +#' d <- nomis_get_metadata("NM_1_1", "geography", "1879048226") #' #' tibble::glimpse(d) #' -#' e <- nomis_get_metadata('NM_1_1', 'item', geography = 1879048226, sex = 5) +#' e <- nomis_get_metadata("NM_1_1", "item", geography = 1879048226, sex = 5) #' #' print(e) #' -#' f <- nomis_get_metadata('NM_1_1', 'item', search = "*married*") +#' f <- nomis_get_metadata("NM_1_1", "item", search = "*married*") #' #' tibble::glimpse(f) #' } - +#' nomis_get_metadata <- function(id, concept = NULL, type = NULL, search = NULL, additional_queries = NULL, ...) { diff --git a/R/overview.R b/R/overview.R index fbaf3df..5032e09 100644 --- a/R/overview.R +++ b/R/overview.R @@ -53,19 +53,23 @@ #' @seealso [nomis_data_info()] #' @seealso [nomis_get_metadata()] #' -#' @examples \donttest{ +#' @examples +#' \donttest{ #' library(dplyr) #' #' q <- nomis_overview("NM_1650_1") #' -#' q %>% tidyr::unnest(name) %>% glimpse() +#' q %>% +#' tidyr::unnest(name) %>% +#' glimpse() #' #' s <- nomis_overview("NM_1650_1", select = c("Units", "Keywords")) #' -#' s %>% tidyr::unnest(name) %>% glimpse() +#' s %>% +#' tidyr::unnest(name) %>% +#' glimpse() #' } - - +#' nomis_overview <- function(id, select = NULL) { if (missing(id)) { stop("The dataset ID must be specified.", call. = FALSE) diff --git a/R/search.R b/R/search.R index f6e524f..8048ed2 100644 --- a/R/search.R +++ b/R/search.R @@ -29,10 +29,11 @@ #' @export #' @seealso [nomis_content_type()] #' -#' @examples \donttest{ -#' x <- nomis_search(name = '*seekers*') +#' @examples +#' \donttest{ +#' x <- nomis_search(name = "*seekers*") #' -#' y <- nomis_search(keywords = 'Claimants') +#' y <- nomis_search(keywords = "Claimants") #' #' # Return metadata of all datasets with content_type "sources". #' a <- nomis_search(content_type = "sources") @@ -42,8 +43,7 @@ #' # source ID "acses" #' b <- nomis_search(content_type = "sources-acses") #' } - - +#' nomis_search <- function(name = NULL, description = NULL, keywords = NULL, content_type = NULL, units = NULL) { if (length(name) > 0) { diff --git a/R/utils-get-data.R b/R/utils-get-data.R index b3eef13..c44069a 100644 --- a/R/utils-get-data.R +++ b/R/utils-get-data.R @@ -20,24 +20,26 @@ nomis_get_data_util <- function(query) { ) } - df <- tryCatch({ - httr::content(api_get) - }, - error = function(cond) { - message( - "It is likely that you have been automatically rate limited ", - "by the Nomis API.\n", - "You can make smaller data requests, or try again later.\n\n", - "Here's the original error message:\n", cond - ) - - return(NA) - }, warning = function(cond) { - stop("The API request did not return any results.\n", - "Please check your parameters.", - call. = FALSE - ) - } + df <- tryCatch( + { + httr::content(api_get) + }, + error = function(cond) { + message( + "It is likely that you have been automatically rate limited ", + "by the Nomis API.\n", + "You can make smaller data requests, or try again later.\n\n", + "Here's the original error message:\n", cond + ) + + return(NA) + }, + warning = function(cond) { + stop("The API request did not return any results.\n", + "Please check your parameters.", + call. = FALSE + ) + } ) if ("OBS_VALUE" %in% names(df)) { @@ -45,5 +47,4 @@ nomis_get_data_util <- function(query) { } df - -} \ No newline at end of file +} diff --git a/R/utils-tidy.R b/R/utils-tidy.R index 45be201..70f6417 100644 --- a/R/utils-tidy.R +++ b/R/utils-tidy.R @@ -13,7 +13,7 @@ nomis_tidy <- function(df, tidy_style) { } else if (tidy_style == "period.case") { names(df) <- gsub("_", "\\.", names(df), perl = TRUE) } - } + } df } diff --git a/man/nomis_codelist.Rd b/man/nomis_codelist.Rd index 5d72ca6..e4dedc3 100644 --- a/man/nomis_codelist.Rd +++ b/man/nomis_codelist.Rd @@ -39,6 +39,7 @@ y <- nomis_codelist("NM_1_1", "geography", search = "*london") z <- nomis_codelist("NM_161_1", "cause_of_death") } + } \seealso{ \code{\link[=nomis_data_info]{nomis_data_info()}} diff --git a/man/nomis_content_type.Rd b/man/nomis_content_type.Rd index 697475a..0a790cb 100644 --- a/man/nomis_content_type.Rd +++ b/man/nomis_content_type.Rd @@ -16,7 +16,7 @@ A tibble with metadata on a given content type. } \description{ Nomis content type metadata is included in annotation tags, in the form of -\code{contenttype/} in the \code{annotationtitle} column in +\verb{contenttype/} in the \code{annotationtitle} column in the \code{annotations.annotation} list-column returned from \code{\link[=nomis_data_info]{nomis_data_info()}}. For example, the content types returned from dataset "NM_1658_1", using \code{nomis_data_info("NM_1658_1")}, are @@ -32,6 +32,7 @@ b <- nomis_content_type("sources", id = "census") tibble::glimpse(b) } + } \seealso{ \code{\link[=nomis_search]{nomis_search()}} diff --git a/man/nomis_data_info.Rd b/man/nomis_data_info.Rd index 3ca95e6..360c55e 100644 --- a/man/nomis_data_info.Rd +++ b/man/nomis_data_info.Rd @@ -26,11 +26,11 @@ x <- nomis_data_info() tibble::glimpse(x) # Get info on a particular dataset -y <- nomis_data_info('NM_1658_1') +y <- nomis_data_info("NM_1658_1") tibble::glimpse(y) - } + } \seealso{ \code{\link[=nomis_get_data]{nomis_get_data()}} diff --git a/man/nomis_get_data.Rd b/man/nomis_get_data.Rd index f45d45c..a4c00cf 100644 --- a/man/nomis_get_data.Rd +++ b/man/nomis_get_data.Rd @@ -4,10 +4,21 @@ \alias{nomis_get_data} \title{Retrieve Nomis datasets} \usage{ -nomis_get_data(id, time = NULL, date = NULL, geography = NULL, - sex = NULL, measures = NULL, additional_queries = NULL, - exclude_missing = FALSE, select = NULL, tidy = FALSE, - tidy_style = "snake_case", query_id = NULL, ...) +nomis_get_data( + id, + time = NULL, + date = NULL, + geography = NULL, + sex = NULL, + measures = NULL, + additional_queries = NULL, + exclude_missing = FALSE, + select = NULL, + tidy = FALSE, + tidy_style = "snake_case", + query_id = NULL, + ... +) } \arguments{ \item{id}{A string containing the ID of the dataset to retrieve, @@ -73,7 +84,7 @@ only females and \code{5} only males. Defaults to \code{NULL}, equivalent to \code{c(5,6,7)} for datasets where sex is an option. For datasets using \code{"C_SEX"}, \code{0} will return results for males and females, \code{1} only males and \code{2} only females. Some datasets use \code{"GENDER"} with the same values -as \code{"SEX"}, which works with both \code{sex = } and \code{gender = } +as \code{"SEX"}, which works with both \verb{sex = } and \verb{gender = } as a dot parameter.} \item{measures}{The code for the statistical measure(s) to include in the @@ -156,52 +167,69 @@ data published. \donttest{ # Return data on Jobseekers Allowance for each country in the UK -jobseekers_country <- nomis_get_data(id = "NM_1_1", time = "latest", - geography = "TYPE499", - measures = c(20100, 20201), sex = 5) +jobseekers_country <- nomis_get_data( + id = "NM_1_1", time = "latest", + geography = "TYPE499", + measures = c(20100, 20201), sex = 5 +) tibble::glimpse(jobseekers_country) # Return data on Jobseekers Allowance for Wigan -jobseekers_wigan <- nomis_get_data(id = "NM_1_1", time = "latest", - geography = "1879048226", - measures = c(20100, 20201), sex = "5") +jobseekers_wigan <- nomis_get_data( + id = "NM_1_1", time = "latest", + geography = "1879048226", + measures = c(20100, 20201), sex = "5" +) tibble::glimpse(jobseekers_wigan) # annual population survey - regional - employment by occupation -emp_by_occupation <- nomis_get_data(id = "NM_168_1", time = "latest", - geography = "2013265925", sex = "0", - select = c("geography_code", - "C_OCCPUK11H_0_NAME", "obs_vAlUE")) +emp_by_occupation <- nomis_get_data( + id = "NM_168_1", time = "latest", + geography = "2013265925", sex = "0", + select = c( + "geography_code", + "C_OCCPUK11H_0_NAME", "obs_vAlUE" + ) +) tibble::glimpse(emp_by_occupation) -# Deaths in 2016 and 2015 by three specified causes, +# Deaths in 2016 and 2015 by three specified causes, # identified with nomis_get_metadata() -death <- nomis_get_data("NM_161_1", date = c("2016","2015"), - geography = "TYPE480", - cause_of_death = c(10300, 102088, 270)) +death <- nomis_get_data("NM_161_1", + date = c("2016", "2015"), + geography = "TYPE480", + cause_of_death = c(10300, 102088, 270) +) tibble::glimpse(death) # All causes of death in London in 2016 -london_death <- nomis_get_data("NM_161_1", date = c("2016"), - geography = "2013265927", sex = 1, age = 0) +london_death <- nomis_get_data("NM_161_1", + date = c("2016"), + geography = "2013265927", sex = 1, age = 0 +) tibble::glimpse(london_death) } \dontrun{ - # Results in an error because `measure` is mistaken for `measures` - mort_data1 <- nomis_get_data(id = "NM_161_1", date = "2016", - geography = "TYPE464", sex = 0, cause_of_death = "10381", - age = 0, measure = 6) - - # Does not error because `measures` is specified - mort_data2 <- nomis_get_data(id = "NM_161_1", date = "2016", - geography = "TYPE464", sex = 0, measures = NULL, - cause_of_death = "10381", age = 0, measure = 6) +# Results in an error because `measure` is mistaken for `measures` +mort_data1 <- nomis_get_data( + id = "NM_161_1", date = "2016", + geography = "TYPE464", sex = 0, cause_of_death = "10381", + age = 0, measure = 6 +) + +# Does not error because `measures` is specified +mort_data2 <- nomis_get_data( + id = "NM_161_1", date = "2016", + geography = "TYPE464", sex = 0, measures = NULL, + cause_of_death = "10381", age = 0, measure = 6 +) } + } \seealso{ \code{\link[=nomis_data_info]{nomis_data_info()}} diff --git a/man/nomis_get_metadata.Rd b/man/nomis_get_metadata.Rd index 86e4806..67afee7 100644 --- a/man/nomis_get_metadata.Rd +++ b/man/nomis_get_metadata.Rd @@ -4,8 +4,14 @@ \alias{nomis_get_metadata} \title{Nomis metadata concepts and types} \usage{ -nomis_get_metadata(id, concept = NULL, type = NULL, search = NULL, - additional_queries = NULL, ...) +nomis_get_metadata( + id, + concept = NULL, + type = NULL, + search = NULL, + additional_queries = NULL, + ... +) } \arguments{ \item{id}{The ID of the particular dataset. Returns no data if not specified.} @@ -45,32 +51,33 @@ metadata for a given dataset, see \code{\link[=nomis_overview]{nomis_overview()} } \examples{ \donttest{ -a <- nomis_get_metadata('NM_1_1') +a <- nomis_get_metadata("NM_1_1") tibble::glimpse(a) -b <- nomis_get_metadata('NM_1_1', 'geography') +b <- nomis_get_metadata("NM_1_1", "geography") tibble::glimpse(b) # returns all types of geography -c <- nomis_get_metadata('NM_1_1', 'geography', 'TYPE') +c <- nomis_get_metadata("NM_1_1", "geography", "TYPE") tibble::glimpse(c) # returns geography types available within Wigan -d <- nomis_get_metadata('NM_1_1', 'geography', '1879048226') +d <- nomis_get_metadata("NM_1_1", "geography", "1879048226") tibble::glimpse(d) -e <- nomis_get_metadata('NM_1_1', 'item', geography = 1879048226, sex = 5) +e <- nomis_get_metadata("NM_1_1", "item", geography = 1879048226, sex = 5) print(e) -f <- nomis_get_metadata('NM_1_1', 'item', search = "*married*") +f <- nomis_get_metadata("NM_1_1", "item", search = "*married*") tibble::glimpse(f) } + } \seealso{ \code{\link[=nomis_data_info]{nomis_data_info()}} diff --git a/man/nomis_overview.Rd b/man/nomis_overview.Rd index 3753906..92a3027 100644 --- a/man/nomis_overview.Rd +++ b/man/nomis_overview.Rd @@ -63,12 +63,17 @@ library(dplyr) q <- nomis_overview("NM_1650_1") -q \%>\% tidyr::unnest(name) \%>\% glimpse() +q \%>\% + tidyr::unnest(name) \%>\% + glimpse() s <- nomis_overview("NM_1650_1", select = c("Units", "Keywords")) -s \%>\% tidyr::unnest(name) \%>\% glimpse() +s \%>\% + tidyr::unnest(name) \%>\% + glimpse() } + } \seealso{ \code{\link[=nomis_data_info]{nomis_data_info()}} diff --git a/man/nomis_search.Rd b/man/nomis_search.Rd index 0c671a9..05b6e2c 100644 --- a/man/nomis_search.Rd +++ b/man/nomis_search.Rd @@ -4,8 +4,13 @@ \alias{nomis_search} \title{Search Nomis datasets} \usage{ -nomis_search(name = NULL, description = NULL, keywords = NULL, - content_type = NULL, units = NULL) +nomis_search( + name = NULL, + description = NULL, + keywords = NULL, + content_type = NULL, + units = NULL +) } \arguments{ \item{name}{A string or character vector of strings to search for in @@ -37,9 +42,9 @@ beginning and/or end of each search string. } \examples{ \donttest{ -x <- nomis_search(name = '*seekers*') +x <- nomis_search(name = "*seekers*") -y <- nomis_search(keywords = 'Claimants') +y <- nomis_search(keywords = "Claimants") # Return metadata of all datasets with content_type "sources". a <- nomis_search(content_type = "sources") @@ -49,6 +54,7 @@ a <- nomis_search(content_type = "sources") # source ID "acses" b <- nomis_search(content_type = "sources-acses") } + } \seealso{ \code{\link[=nomis_content_type]{nomis_content_type()}} diff --git a/tests/testthat/test_get_data.R b/tests/testthat/test_get_data.R index 116ef3d..b10b5ba 100644 --- a/tests/testthat/test_get_data.R +++ b/tests/testthat/test_get_data.R @@ -73,19 +73,25 @@ test_that("nomis_get_data return expected format", { expect_length(x_select, 3) expect_type(x_select, "list") expect_true(tibble::is_tibble(x_select)) - - - select_no_obs <- nomis_get_data(id = "NM_1208_1", time = "latest", - USUAL_RESIDENCE = "TYPE499", - PLACE_OF_WORK = "TYPE499", - TRANSPORT_POWPEW11 = "2", - select = c("USUAL_RESIDENCE_NAME", - "PLACE_OF_WORK_NAME")) + + + select_no_obs <- nomis_get_data( + id = "NM_1208_1", time = "latest", + USUAL_RESIDENCE = "TYPE499", + PLACE_OF_WORK = "TYPE499", + TRANSPORT_POWPEW11 = "2", + select = c( + "USUAL_RESIDENCE_NAME", + "PLACE_OF_WORK_NAME" + ) + ) expect_length(select_no_obs, 2) expect_true(tibble::is_tibble(select_no_obs)) - expect_true(all(names(select_no_obs)==c("USUAL_RESIDENCE_NAME", - "PLACE_OF_WORK_NAME"))) - + expect_true(all(names(select_no_obs) == c( + "USUAL_RESIDENCE_NAME", + "PLACE_OF_WORK_NAME" + ))) + mort_data1 <- nomis_get_data( id = "NM_161_1", date = "2016", tidy = TRUE,