Skip to content

Commit

Permalink
fixing select issue (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanodell committed Jan 9, 2019
1 parent 0acd594 commit 7047fa6
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: nomisr
Type: Package
Title: Access 'Nomis' UK Labour Market Data
Version: 0.4.0.9000
Version: 0.4.1
Authors@R: c(
person(
"Evan", "Odell", email = "evanodell91@gmail.com", role = c("aut", "cre"),
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# nomisr 0.4.0.9000
# nomisr 0.4.1

* Adding `query_id` parameter to `nomis_get_data()`

* Changed documentation to use `roxygen` markdown

## Bug fixes

* Fixed bug where the `select` parameter in `nomis_get_data()` didn't work if
"OBS_VALUE" was not one of the variables. (@JimShady, #12)


# nomisr 0.4.0

Expand Down
4 changes: 2 additions & 2 deletions R/data_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@
#' @param exclude_missing If `TRUE`, excludes all missing values.
#' Defaults to `FALSE`.
#'
#' @param select A character vector of one or more variables to select,
#' excluding all others. `select` is not case sensitive.
#' @param select A character vector of one or more variables to include in
#' the returned data, excluding all others. `select` is not case sensitive.
#'
#' @param tidy Logical parameter. If `TRUE`, converts variable names to
#' `snake_case`, or another style as specified by the
Expand Down
9 changes: 7 additions & 2 deletions R/utils-get-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ nomis_get_data_util <- function(query) {
readr::read_csv(
api_get$url,
col_types = readr::cols(
.default = "c",
OBS_VALUE = "d"
.default = "c"
)
)
},
Expand All @@ -46,5 +45,11 @@ nomis_get_data_util <- function(query) {
}
)

if ("OBS_VALUE" %in% names(df)) {
df$OBS_VALUE <- as.double(df$OBS_VALUE)
}

df


}
9 changes: 4 additions & 5 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

## Release summary

This is an update of the `nomisr` package, version number 0.4.0.
This version has new `tidy` and `tidy_style` parameters in the
`nomis_get_data()` function, improvements to documentation, and a CITATION
file that now refers to the package's JOSS paper.
This is an update of the `nomisr` package, version number 0.4.1.
This version has a new `query_id` parameter in the `nomis_get_data()` function
and fixes a bug with the `select` parameter in `nomis_get_data()`.

## Test environments
* local OS X install, R 3.5.1
* local OS X install, R 3.5.2
* ubuntu 14.04 (on travis-ci), (devel and release)
* win-builder (devel and release)

Expand Down
4 changes: 2 additions & 2 deletions man/nomis_get_data.Rd

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

13 changes: 13 additions & 0 deletions tests/testthat/test_get_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ 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"))
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")))


mort_data1 <- nomis_get_data(
id = "NM_161_1", date = "2016", tidy = TRUE,
Expand Down

0 comments on commit 7047fa6

Please sign in to comment.