| local_inla_options {INLA} | R Documentation |
Helper for locally setting inla options
Description
Locally sets INLA options with inla.setOption() and restores
when the calling function terminates, like withr::local_options() does for
global R options.
Usage
local_inla_options(..., .envir = parent.frame(), .save_only = FALSE)
Arguments
... |
Named arguments to be passed to |
.envir |
The environment in which the options should be set. Defaults to the calling environment. |
.save_only |
If |
Value
logical; If the option setting was successful, TRUE is returned,
otherwise FALSE.
Examples
print(paste0("Before: ", INLA::inla.getOption("num.threads")))
local({
fun1 <- function() { INLA::inla.setOption("num.threads" = "1:1") }
fun2 <- function() {
local_inla_options(num.threads = NULL, .save_only = TRUE)
print(paste0("Local value: ", INLA::inla.getOption("num.threads")))
fun1()
print(paste0("Local changed value: ",
INLA::inla.getOption("num.threads")))
invisible()
}
fun2()
print(paste0("Restored: ", INLA::inla.getOption("num.threads")))
local_inla_options(num.threads = "2:1")
print(paste0("Change: ", INLA::inla.getOption("num.threads")))
fun2()
print(paste0("Restored: ",
INLA::inla.getOption("num.threads")))
})
print(paste0("After: ", INLA::inla.getOption("num.threads")))
[Package INLA version 25.10.19 Index]