# \donttest{
library(data.table)
# 1. Create dummy data (Only 'I' and 'C' counts are required by this function)
DT <- data.table(
I = rpois(50, lambda = 4),
C = rpois(50, lambda = 3)
)
# 2. Define global paths using tempdir() (Fixes CRAN policy)
# run_hmm expects these variables to exist in the global environment
tmp_dir <- tempdir()
dir_csv <- file.path(tmp_dir, "csv")
dir_out <- file.path(tmp_dir, "hmm")
dir.create(dir_csv, showWarnings = FALSE, recursive = TRUE)
dir.create(dir_out, showWarnings = FALSE, recursive = TRUE)
# 3. Run the function
# Using nstates=2 for a faster example check
res_hmm <- run_hmm(DT, nstates = 2)
# Inspect result if successful
if (!is.null(res_hmm)) {
print(table(res_hmm$states))
}
# }
Run the code above in your browser using DataLab