# Offline, CRAN-safe example using a tiny seeded model
if (requireNamespace("withr", quietly = TRUE)) {
withr::local_options(writeAlizer.offline = TRUE)
tmp <- withr::local_tempdir()
withr::local_options(writeAlizer.mock_dir = tmp)
# Seed the example artifacts into the temp dir and point the loader there
writeAlizer::wa_seed_example_models("example", dir = tmp)
coh <- import_coh(system.file("extdata", "sample_coh.csv", package = "writeAlizer"))
out <- predict_quality("example", coh)
head(out)
} else {
# Fallback without 'withr' (still CRAN-safe)
old <- options(writeAlizer.offline = TRUE)
on.exit(options(old), add = TRUE)
ex_dir <- writeAlizer::wa_seed_example_models("example", dir = tempdir())
old2 <- options(writeAlizer.mock_dir = ex_dir)
on.exit(options(old2), add = TRUE)
coh <- import_coh(system.file("extdata", "sample_coh.csv", package = "writeAlizer"))
out <- predict_quality("example", coh)
head(out)
}
# Longer, networked demos (skipped on CRAN)
# \donttest{
if (!isTRUE(getOption("writeAlizer.offline", FALSE))) {
rb <- import_rb(system.file("extdata", "sample_rb.csv", package = "writeAlizer"))
print(head(predict_quality("rb_mod3all", rb)))
coh <- import_coh(system.file("extdata", "sample_coh.csv", package = "writeAlizer"))
print(head(predict_quality("coh_mod3all", coh)))
gam <- import_gamet(system.file("extdata", "sample_gamet.csv", package = "writeAlizer"))
print(head(predict_quality("gamet_cws1", gam)))
}
# }
Run the code above in your browser using DataLab