Skip to content

Commit e2f8eee

Browse files
committed
made setspp redundant but backwards compatible with a warning
1 parent 0cd94f5 commit e2f8eee

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

R/simulate_choices.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@
3030
#' )
3131
#' simulate_choices(example_df, ut, setspp = 4, bcoeff = beta)
3232
#'
33-
simulate_choices <- function(data, utility, setspp=NULL, bcoeff, decisiongroups = c(0, 1), manipulations = list(), preprocess_function = NULL) { # the part in dataset that needs to be repeated in each run
33+
simulate_choices <- function(data, utility, setspp, bcoeff, decisiongroups = c(0, 1), manipulations = list(), preprocess_function = NULL) { # the part in dataset that needs to be repeated in each run
34+
35+
36+
37+
if (!missing(setspp)) {
38+
warning(
39+
"`setspp` is deprecated and ignored. ",
40+
"The number of choice sets per respondent is inferred from `data`.",
41+
call. = FALSE
42+
)
43+
}
3444

3545
if (!is.null(preprocess_function)) {
3646
if (!is.function(preprocess_function)) {

man/simulate_choices.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-simulate_choices.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ formattedes <- readdesign(design = design, designtype = "spdesign")
3939
data <- simulateDCE::createDataset(formattedes, respondents = resps)
4040

4141

42+
test_that("simulate_choices() warns when deprecated setspp is used", {
43+
expect_warning(
44+
simulate_choices(
45+
data = data,
46+
utility = ul,
47+
setspp = 4,
48+
bcoeff = bcoeff
49+
),
50+
regexp = "is deprecated and ignored"
51+
)
52+
})
53+
4254
test_that("simulate_choices() does not error", {
4355
expect_error(
4456
simulate_choices(data = data, bcoeff = bcoeff, u = ul),

0 commit comments

Comments
 (0)