The model represents a community, i.e. a set of interacting objects called agents. Their location is described by a pattern that evolves along a timeline.

Public fields

pattern

The pattern which describes the location of agents.

type

The type of individuals. Informational only.

timeline

A numeric vector.

last_time

The last time (in the time line) the model has been run.

run_patterns

The past patterns of the model, obtained by run and saved.

Methods


Method new()

Create a new instance of this R6 class.

Usage

community_model$new(pattern = NULL, timeline = 0, type = "Species")

Arguments

pattern

The pattern which describes the location of agents.

timeline

A numeric vector that contains the points of time of interest.

type

The type of individuals. Informational only.


Method plot()

Default plot method: plots the pattern. To be overridden.

Usage

community_model$plot(
  time = NULL,
  sleep = animation::ani.options("interval"),
  ...
)

Arguments

time

The point of the timeline considered. Its value should be in timeline.

sleep

The time (in ms) to sleep between each step of the evolution of the model.

...

Extra arguments to be passed to methods.


Method autoplot()

Make a ggplot2::ggplot of the pattern. To be overridden.

Usage

community_model$autoplot(time = NULL, ...)

Arguments

time

The point of the timeline considered. Its value should be in timeline.

...

Extra arguments to be passed to methods.


Method run()

Run the model.

Usage

community_model$run(
  animate = FALSE,
  sleep = animation::ani.options("interval"),
  save = FALSE,
  more_time = NULL
)

Arguments

animate

if TRUE, the evolution of the model is shown in an animation.

sleep

The time (in ms) to sleep between each step of the evolution of the model.

save

if TRUE, the evolution of the model is saved. if FALSE, only the final step is saved.

more_time

A numeric vector that extends the timeline.


Method saved_pattern()

Return the pattern at the chosen time.

Usage

community_model$saved_pattern(time)

Arguments

time

The point of the timeline considered. Its value should be in timeline.


Method along_time()

Apply the function FUN to the saved patterns along time and return a dataframe with columns x for time and y for the results of FUN. FUN must return a single value.

Usage

community_model$along_time(FUN, ...)

Arguments

FUN

A function to apply to each pattern of the evolution of the model. It must return a single, numeric value.

...

Extra arguments to be passed to methods.


Method clone()

The objects of this class are cloneable with this method.

Usage

community_model$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

myModel <- community_matrixmodel$new()
myModel$autoplot()