-
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 #48 from getwilds/vignette
created handle and test non english/ edited demo vignette
- Loading branch information
Showing
13 changed files
with
181 additions
and
33 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
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 Non-English Language Values to Code | ||
#' | ||
#' This function returns a matching code value for Non-English Language for the api to use to get data from State Cancer Profiles | ||
#' | ||
#' @param language "language isolation" | ||
#' | ||
#' @importFrom rlang is_na | ||
#' | ||
#' @returns A string for its respective language Value | ||
#' | ||
#' @noRd | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' handle_non_english("language isolation") | ||
#' } | ||
handle_non_english <- function(language) { | ||
language <- tolower(language) | ||
|
||
language_mapping <- c( | ||
"language isolation" = "00015" | ||
) | ||
|
||
language_code <- language_mapping[language] | ||
|
||
if (is_na(language_code)) { | ||
stop("Invalid language input, please check the documentation for valid inputs") | ||
} | ||
|
||
return(as.character(language_code)) | ||
} |
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
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
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 crowding | ||
#' | ||
#' This testthat file tests the handle-crowding function | ||
test_that("handle crowding correctly maps crowding", { | ||
result <- sapply(c("household with >1 person per room"), handle_crowding) | ||
expected <- c(`household with >1 person per room` = "00027") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle crowding expects errors for incorrect arguments", { | ||
expect_error(handle_crowding("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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Test Handle Non-english | ||
#' | ||
#' This testthat file tests the handle_non_english function | ||
test_that("handle_non_english correctly maps language", { | ||
result <- sapply(c("language isolation"), handle_non_english) | ||
expected <- c(`language isolation` = "00015") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle_non_english expects errors for incorrect arguments", { | ||
expect_error(handle_non_english("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