-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
206 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ Imports: | |
jsonlite, | ||
tibble, | ||
readr, | ||
dplyr | ||
dplyr, | ||
curl | ||
RoxygenNote: 6.0.1 | ||
Suggests: | ||
knitr, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(nomis_codes) | ||
export(nomis_data_info) | ||
export(nomis_get_data) | ||
export(nomis_search) | ||
import(curl) | ||
import(dplyr) | ||
import(jsonlite) | ||
import(readr) | ||
import(tibble) | ||
importFrom(readr,read_csv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
|
||
|
||
|
||
#' Variable codes | ||
#' | ||
#' Retrieve all code options of all datasets, code options for a given | ||
#' dataset, or the all the options for a given code variable from a | ||
#' particular dataset. | ||
#' | ||
#' @param id The ID of the particular dataset. If both \code{id} and | ||
#' \code{code} are left empty, returns all available codes for all datasets. | ||
#' @param code The variable name to return options for. If left empty, | ||
#' returns all options for the dataset specified by \code{id}. | ||
#' | ||
#' @return A list of options. | ||
#' @export | ||
#' | ||
#' @examples \dontrun{ | ||
#' | ||
#' z <- nomis_codes("NM_7_1", "geography") | ||
#' | ||
#' } | ||
#' | ||
nomis_codes <- function(id, code){ | ||
|
||
if(missing(id)) stop("The dataset ID must be specified to return options for a given code.") | ||
|
||
if(missing(code)) { | ||
|
||
q <- nomis_data_info(id) | ||
|
||
df <- tibble::as_tibble(as.data.frame(q$components.dimension)) | ||
|
||
df$isfrequencydimension[is.na(df$isfrequencydimension)] <- "false" | ||
|
||
} else { | ||
|
||
qq <- paste0("https://www.nomisweb.co.uk/api/v01/dataset/",id,"/",code,"/TYPE.def.sdmx.json?") | ||
|
||
a <- jsonlite::fromJSON(qq, flatten=TRUE) | ||
|
||
x <- as.data.frame(a$structure$codelists$codelist$code) | ||
|
||
df <- tibble::tibble( | ||
description=x$description.value, | ||
value=x$value | ||
) | ||
|
||
} | ||
|
||
df | ||
|
||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ nomis_query_util <- function(query){ | |
|
||
df | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters