Skip to content

Commit

Permalink
Fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chartgerink committed Aug 1, 2024
1 parent 6a92ed0 commit e8f2986
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion R/make_datatagr.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @param x a `data.frame` or a `tibble`
#'
#' @param ... <[`dynamic-dots`][rlang::dyn-dots]> A series of tags provided as
#' `tag_name = "column_name"`. When specifying tags, please also see
#' `tag_name = "column_name"`. When specifying tags, please also see
#' `tag_defaults` to specify default values.
#'
#' @param tag_defaults a list of default values for the provided tags. Defaults
Expand Down
7 changes: 6 additions & 1 deletion R/validate_datatagr.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
#' x
#'
#' ## validation
#' validate_datatagr(x)
#' validate_datatagr(x, ref_types = tags_types(
#' id = c("integer", "factor"),
#' date_onset = "Date",
#' age = "numeric",
#' gender = c("factor", "character")
#' ))
#'
#' ## create an invalid datatagr - onset date is a factor
#' x <- measles_hagelloch_1861 %>%
Expand Down
7 changes: 6 additions & 1 deletion R/validate_tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
#' x
#'
#' ## validation
#' validate_tags(x)
#' validate_datatagr(x, ref_types = tags_types(
#' id = c("integer", "factor"),
#' date_onset = "Date",
#' age = "numeric",
#' gender = c("factor", "character")
#' ))
#'
#' ## hack to create an invalid tags (missing defaults)
#' attr(x, "tags") <- list(id = "case_ID")
Expand Down
5 changes: 4 additions & 1 deletion R/validate_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
#' tryCatch(validate_types(x), error = paste)
#'
#' ## to allow other types, e.g. gender to be integer, character or factor
#' validate_types(x, tags_types(gender = c("integer", "character", "factor")))
#' validate_types(x, tags_types(id = "integer", gender = c(
#' "integer",
#' "character", "factor"
#' )))
#' }
validate_types <- function(x, ref_types = tags_types()) {
checkmate::assert_class(x, "datatagr")
Expand Down
7 changes: 6 additions & 1 deletion man/validate_datatagr.Rd

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

7 changes: 6 additions & 1 deletion man/validate_tags.Rd

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

5 changes: 4 additions & 1 deletion man/validate_types.Rd

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

6 changes: 4 additions & 2 deletions tests/testthat/test-validate_datatagr.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ test_that("tests for validate_datatagr", {

x <- make_datatagr(cars, gender = "speed")
expect_error(
validate_datatagr(x, ref_types = tags_types(gender = c('character',
'factor'))),
validate_datatagr(x, ref_types = tags_types(gender = c(
"character",
"factor"
))),
"- gender: Must inherit from class 'character'/'factor'"
)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-validate_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_that("validate_types() validates types", {
expect_silent(
expect_identical(
x,
validate_types(x, ref_types = tags_types(age = 'numeric'))
validate_types(x, ref_types = tags_types(age = "numeric"))
)
)

Expand Down

0 comments on commit e8f2986

Please sign in to comment.