init_logger: Initialize logger.

Description Usage Arguments Value See Also Examples

View source: R/logger.R

Description

Generates a fairly flexible container to log stuff.

Usage

1
init_logger(what, init.size, at = NULL, to = NULL)

Arguments

what

[named(character)]
Named character vector. The names (i.e. names(what)) describe which elements we want to log and the actual values represent the types/modes these values are stored as. Possible values are “integer”, “numeric”, “character”, “logical” for the respective scalar atomic values or “list” for any other complex R objects, e.g., matrices, lists etc. Note that internally c("iter" = "numeric") is attached automatically and iter must be passed to |link{update_logger} in subsequent calls.

init.size

[integer(1)]
Initial size of the log.

at

[integer]
Optional integer vector of times when logging should take place. If the iteration counter is in at, the state is logged, otherwise it is not.

to

[character(1)]
File path to log-directory. If not NULL, each call to update_logger stores the serialized state in file “<to>/<iteration>.rds”.

Value

[enviroment] Logger environment.

See Also

update_logger

Examples

1
2
3
4
5
6
7
log = init_logger(c("P" = "list", "f" = "list", "C" = "character"), init.size = 5L, at = c(1, 3))

# note that div is not subject to logging since it was not specified in init_logger
update_logger(log, P = matrix(runif(10), ncol = 2L), C = "a", f = runif(10), iter = 1, div = letters[1:3])
update_logger(log, P = matrix(runif(10), ncol = 2L), C = "b", f = runif(10), iter = 2, div = letters[1:3])
update_logger(log, P = matrix(runif(10), ncol = 2L), C = "a", f = runif(10), iter = 3, div = letters[1:3])
print(log$df)

jakobbossek/evoprob documentation built on Dec. 20, 2021, 9 p.m.