diff --git a/R/case-when-variable.R b/R/case-when-variable.R index 4674ee102..81f3eed07 100644 --- a/R/case-when-variable.R +++ b/R/case-when-variable.R @@ -5,7 +5,7 @@ #' side is where to get the value if the condition on the left-hand side is #' true. This must be either a Crunch Categorical variable or a Category. #' -#' @param ... formulas where the left hand side is a CrunchExpression (or `TRUE` +#' @param ... formulas where the left hand side is a `CrunchLogicalExpression` (or `TRUE` #' to indicate the "else" case that will be met if all the other expression are #' not met) and the right hand side is a CrunchVariable that should be filled in, #' a `Category` object describing the Category it should be used, a string diff --git a/man/makeCaseWhenVariable.Rd b/man/makeCaseWhenVariable.Rd index 8c4e07e47..2b96e0345 100644 --- a/man/makeCaseWhenVariable.Rd +++ b/man/makeCaseWhenVariable.Rd @@ -10,7 +10,7 @@ makeCaseWhenVariable(..., data = NULL, formulas = NULL, name) caseWhenExpr(..., data = NULL, formulas = NULL) } \arguments{ -\item{...}{formulas where the left hand side is a CrunchExpression (or \code{TRUE} +\item{...}{formulas where the left hand side is a \code{CrunchLogicalExpression} (or \code{TRUE} to indicate the "else" case that will be met if all the other expression are not met) and the right hand side is a CrunchVariable that should be filled in, a \code{Category} object describing the Category it should be used, a string diff --git a/tests/testthat/test-case-when-variable.R b/tests/testthat/test-case-when-variable.R index 6e4503fed..1b309bab9 100644 --- a/tests/testthat/test-case-when-variable.R +++ b/tests/testthat/test-case-when-variable.R @@ -38,8 +38,8 @@ with_mock_crunch({ expect_equal( unclass(toJSON( caseWhenExpr( - between(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), - between(ds$birthyr, 1980, 1990) ~ ds$gender, + crunchBetween(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), + crunchBetween(ds$birthyr, 1980, 1990) ~ ds$gender, TRUE ~ Category(name = "Missed Q", missing = TRUE) )@expression )), @@ -61,14 +61,14 @@ with_mock_crunch({ test_that("caseWhenExpr handles formulas argument", { expect_equal( caseWhenExpr( - between(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), - between(ds$birthyr, 1980, 1990) ~ ds$gender, + crunchBetween(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), + crunchBetween(ds$birthyr, 1980, 1990) ~ ds$gender, TRUE ~ Category(name = "Missed Q", missing = TRUE) ), caseWhenExpr( formulas = list( - between(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), - between(ds$birthyr, 1980, 1990) ~ ds$gender, + crunchBetween(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), + crunchBetween(ds$birthyr, 1980, 1990) ~ ds$gender, TRUE ~ Category(name = "Missed Q", missing = TRUE) ) ) @@ -78,14 +78,14 @@ with_mock_crunch({ test_that("caseWhenExpr handles data argument", { expect_equal( caseWhenExpr( - between(birthyr, 1970, 1980) ~ Category(name = "Hello"), - between(birthyr, 1980, 1990) ~ gender, + crunchBetween(birthyr, 1970, 1980) ~ Category(name = "Hello"), + crunchBetween(birthyr, 1980, 1990) ~ gender, TRUE ~ Category(name = "Missed Q", missing = TRUE), data = ds ), caseWhenExpr( - between(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), - between(ds$birthyr, 1980, 1990) ~ ds$gender, + crunchBetween(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), + crunchBetween(ds$birthyr, 1980, 1990) ~ ds$gender, TRUE ~ Category(name = "Missed Q", missing = TRUE) ) ) @@ -94,15 +94,15 @@ with_mock_crunch({ test_that("makeCaseWhenVariable handles data argument", { expect_equal( makeCaseWhenVariable( - between(birthyr, 1970, 1980) ~ Category(name = "Hello"), - between(birthyr, 1980, 1990) ~ gender, + crunchBetween(birthyr, 1970, 1980) ~ Category(name = "Hello"), + crunchBetween(birthyr, 1980, 1990) ~ gender, TRUE ~ Category(name = "Missed Q", missing = TRUE), data = ds, name = "test" ), makeCaseWhenVariable( - between(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), - between(ds$birthyr, 1980, 1990) ~ ds$gender, + crunchBetween(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), + crunchBetween(ds$birthyr, 1980, 1990) ~ ds$gender, TRUE ~ Category(name = "Missed Q", missing = TRUE), name = "test" ) @@ -112,16 +112,16 @@ with_mock_crunch({ test_that("makeCaseWhenVariable correctly separates dots", { expect_equal( makeCaseWhenVariable( - between(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), - between(ds$birthyr, 1980, 1990) ~ ds$gender, + crunchBetween(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), + crunchBetween(ds$birthyr, 1980, 1990) ~ ds$gender, TRUE ~ Category(name = "Missed Q", missing = TRUE), name = "test", description = "desc" ), VarDef( caseWhenExpr( - between(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), - between(ds$birthyr, 1980, 1990) ~ ds$gender, + crunchBetween(ds$birthyr, 1970, 1980) ~ Category(name = "Hello"), + crunchBetween(ds$birthyr, 1980, 1990) ~ ds$gender, TRUE ~ Category(name = "Missed Q", missing = TRUE) ), name = "test",