Skip to content

Instantly share code, notes, and snippets.

@wleoncio
Created April 24, 2024 13:04
Show Gist options
  • Save wleoncio/d5332e5993451359d1453c6dd4c56dcd to your computer and use it in GitHub Desktop.
Save wleoncio/d5332e5993451359d1453c6dd4c56dcd to your computer and use it in GitHub Desktop.
Fix to issue #50
# Adapted from https://github.com/tmatta/lsasim/issues/50#issue-2254039296

# Package, Data and subset
remotes::install_github("tmatta/lsasim", "issue-50")
#> Using GitHub PAT from the git credential store.
#> Skipping install of 'lsasim' from a github remote, the SHA1 (28b71cf3) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(lsasim)
#> This is lsasim 2.1.4-1713963651
set.seed(8078908)
param <- NAEPirtparams::parameters
item_par <- param[param$level %in% 8 & param$subject %in% "Mathematics" & param$year %in% 2015, ]

# Happy path
item_par_1 <- item_par
item_par_1$item <- sample(1e5, nrow(item_par_1))
block_1 <- block_design(10L, item_par_1)

# Sequential items
item_par_2 <- item_par
item_par_2$item <- seq(1, nrow(item_par_2))
block_2 <- block_design(10L, item_par_2)

# Errors
block_design(10L, item_par)
#> Error in block_design(10L, item_par): item_parameters must contain an 'item' column.
item_par$item <- sample(100, size = nrow(item_par), replace = TRUE)
block_design(10L, item_par)
#> Error in block_design(10L, item_par): item_parameters must contain unique 'item' values.

Created on 2024-04-24 with reprex v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment