add_log: Add log to a Container or Entity object

Description Usage Arguments Value Examples

Description

This is an S3 method for adding logs to a Container or Entity object in a microsimulation pipeline. This method passes all the arguments to the log() method of the object in x.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
get_log(x)

## S3 method for class 'Generic'
get_log(x)

## S3 method for class 'World'
get_log(x)

## S3 method for class 'Container'
get_log(x)

add_log(x, ...)

## S3 method for class 'World'
add_log(
  x,
  entity = NULL,
  desc,
  value,
  tag = NA_character_,
  time = .get_sim_time(),
  ...
)

## S3 method for class 'Container'
add_log(x, desc, value, tag = NA_character_, time = .get_sim_time(), ...)

## S3 method for class 'Entity'
add_log(x, desc, value, tag = NA_character_, time = .get_sim_time(), ...)

Arguments

x

(Container|Entity)
an instance of R6::R6Class to add a log entry to.

...

dots

entity

(character)
an Entity classname.

desc

(character(1))
a log description.

value

(any)
an object to be stored. You can even store an xtabs object, if you wish.

tag

(character(1))
a tag, default as NA_character.

time

(integer(1))
a number denoting timestep, not the actual timestamp which is already auto-generated for each log entry.

Value

add_log invinsibly returns x, while get_log returns data.table::data.table with the following structure:

1
2
3
4
5
6
data.table(time = integer(),
           created_timestamp = integer(),
           class = character(),
           tag = character(),
           desc = character(),
           value = list())

Examples

1
2
3
create_toy_world()
add_log(world, entity = "Individual", desc = "count:individuals", value = world$entities$Individual$n())
get_log(world)

dymium-org/dymiumCore documentation built on July 18, 2021, 5:10 p.m.