-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from getwilds/vignette
Vignette
- Loading branch information
Showing
8 changed files
with
200 additions
and
10 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
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,31 @@ | ||
#' Handles workforce Values to Code | ||
#' | ||
#' This function returns a matching code value for workforce for the api to use to get data from State Cancer Profiles | ||
#' | ||
#' @param workforce "unemployed" | ||
#' | ||
#' @importFrom rlang is_na | ||
#' | ||
#' @returns A string for its respective workforce Value | ||
#' | ||
#' @noRd | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' handle_workforce("unemployed") | ||
#' } | ||
handle_workforce <- function(workforce) { | ||
workforce <- tolower(workforce) | ||
|
||
workforce_mapping <- c( | ||
"unemployed" = "00012" | ||
) | ||
|
||
workforce_code <- workforce_mapping[workforce] | ||
|
||
if (is_na(workforce_code)) { | ||
stop("Invalid workforce input, please check the documentation for valid inputs") | ||
} | ||
|
||
return(as.character(workforce_code)) | ||
} |
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
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,13 @@ | ||
#' Test Handle workforce | ||
#' | ||
#' This testthat file tests the handle-workforce function | ||
test_that("handle workforce correctly maps workforce", { | ||
result <- sapply(c("unemployed"), handle_workforce) | ||
expected <- c(`unemployed` = "00012") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle workforce expects errors for incorrect arguments", { | ||
expect_error(handle_workforce("carrot")) | ||
}) |
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