Skip to content

Commit

Permalink
starting process of developing more functions, fleshing out the packa…
Browse files Browse the repository at this point in the history
…ge and purpose
  • Loading branch information
evanodell committed Jan 19, 2018
1 parent f8062f7 commit 61bc805
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 26 deletions.
27 changes: 20 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
Package: nomisr
Type: Package
Title: What the Package Does in One 'Title Case' Line
Version: 1.0
Title: Access nomis data on UK labour market statistics with R
Version: 0.0.0.9000
Date: 2018-01-19
Author: Your Name
Maintainer: Your Name <your@email.com>
Description: One paragraph description of what the package does as one or more full sentences.
License: GPL (>= 2)
Imports: Rcpp (>= 0.12.14)
Authors@R: person("Evan Odell", email="evanodell91@gmail.com",
role=c("aut", "cre"),
comment = c(ORCID='0000-0003-1845-808X'))
Author: Evan Odell [aut, cre]
Maintainer: Evan Odell <evanodell91@gmail.com>
Description: Access UK labour market official statistics from the nomis
database
License: GPL-3
Imports:
Rcpp (>= 0.12.14),
jsonlite,
tibble
LinkingTo: Rcpp
RoxygenNote: 6.0.1
Suggests:
knitr,
rmarkdown,
testthat
VignetteBuilder: knitr
9 changes: 6 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
useDynLib(nomisr, .registration=TRUE)
exportPattern("^[[:alpha:]]+")
importFrom(Rcpp, evalCpp)
# Generated by roxygen2: do not edit by hand

export(nomis_data)
import(jsonlite)
import(tibble)
importFrom(Rcpp,sourceCpp)
2 changes: 1 addition & 1 deletion R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

rcpp_hello_world <- function() {
.Call(`_nomisr_rcpp_hello_world`)
.Call('_nomisr_rcpp_hello_world', PACKAGE = 'nomisr')
}

13 changes: 13 additions & 0 deletions R/data_download.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@



nomis_data_access <- function(id){

q <- jsonlite::fromJSON("https://www.nomisweb.co.uk/api/v01/dataset/NM_1_1.jsonstat.json?", flatten = T)


}


#results <- fromJSONstat("https://www.nomisweb.co.uk/api/v01/dataset/NM_1_1.jsonstat.json?")
##investigate this JSONstat package further - currently 2 years since anything has been done to it, it is still the best way forward?
31 changes: 31 additions & 0 deletions R/data_sets.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

## retrieve all available data sets or the information available in a specific dataset based on its ID


#' Title
#'
#' @param id Dataset ID
#'
# @return
#' @export
#'
# @examples
nomis_data <- function(id){

if(missing(id)){

query <- "/def.sdmx.json"

} else {

query <- paste0("/",id,"/def.sdmx.json")

}

df <- nomis_query_util(query)

}




11 changes: 10 additions & 1 deletion R/nomisr-package.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#' nomisr: Access nomis data on UK labour market statistics with R

#' Documentation available at \url{https://www.nomisweb.co.uk/api/v01/help}

# Docs: https://www.nomisweb.co.uk/api/v01/help

#' @docType package
#' @name nmisr
#' @import jsonlite
#' @import tibble
# @useDynLib nomisr
#' @importFrom Rcpp sourceCpp
NULL
10 changes: 6 additions & 4 deletions R/search.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

nomis_search <- function(search, keyword=FALSE){

mydata <- dplyr::if_else(keyword==FALSE,
jsonlite::fromJSON(paste0("https://www.nomisweb.co.uk/api/v01/dataset/def.sdmx.json?search=*", search, "*"), flatten = TRUE),
jsonlite::fromJSON(paste0("https://www.nomisweb.co.uk/api/v01/dataset/def.sdmx.json?search=keywords-", search, "*"), flatten = TRUE))
query <- dplyr::if_else(keyword==FALSE,
paste0("/def.sdmx.json?search=*", search, "*"),
paste0("/def.sdmx.json?search=keywords-", search, "*")

df <- mydata$structure$keyfamilies$keyfamily
)

df <- nomis_query_util(query)


}
13 changes: 13 additions & 0 deletions R/utils-collect.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


## utility function to download data - may need to expand as time goes on

nomis_collect_util <- function(query){

q <- jsonlite::fromJSON(paste0(collect_root, query), flatten = TRUE)

#df <- tibble::as.tibble(q$structure$keyfamilies$keyfamily)

#df

}
13 changes: 13 additions & 0 deletions R/utils-query.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

## utility function to query - may need to expand as time goes on


nomis_query_util <- function(query){

q <- jsonlite::fromJSON(paste0(query_root, query), flatten = TRUE)

df <- tibble::as.tibble(q$structure$keyfamilies$keyfamily)

df

}
9 changes: 9 additions & 0 deletions R/utils-webroots.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## utility object

# the basic url for all data queries
query_root <- "https://www.nomisweb.co.uk/api/v01/dataset"

# the basic url for all data downloads
collect_root <- "https://www.nomisweb.co.uk/api/v01/dataset"

p_load(rjstat)
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ knitr::opts_chunk$set(

# nomisr

The goal of nomisr is to ...
`nomisr` is for accessing [nomis](https://www.nomisweb.co.uk/) data on UK labour market statistics with R.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
nomisr
======

The goal of nomisr is to ...
`nomisr` is for accessing [nomis](https://www.nomisweb.co.uk/) data on UK labour market statistics with R.

Installation
------------
Expand Down
8 changes: 0 additions & 8 deletions Read-and-delete-me

This file was deleted.

12 changes: 12 additions & 0 deletions man/nmisr.Rd

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

14 changes: 14 additions & 0 deletions man/nomis_data.Rd

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

4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(nomisr)

test_check("nomisr")

0 comments on commit 61bc805

Please sign in to comment.