data_writer {villager}R Documentation

Data Writer

Description

A class responsible for the simulation data to disk.

Details

This class can be subclasses to provide advanced data writing to other data sources. This should also be subclassed if the agent and resource classes are subclasses, to write any additional fields to the data source.

Methods

write()

Writes the agent and resources to disk.

Create a new data writer.

Public fields

results_directory

The folder where the simulation results are written to

agent_filename

The location where the agents are written to

resource_filename

The location where the resources are written to

Methods

Public methods


Method new()

Creates a new data writer object that has optional paths for data files.

Usage
data_writer$new(
  results_directory = "results",
  agent_filename = "agents.csv",
  resource_filename = "resources.csv"
)
Arguments
results_directory

The directory where the results file is written to

agent_filename

The name of the file for the agent data

resource_filename

The name of the file for the resource data

Returns

A new agent object Writes a village's state to disk.


Method write()

Takes a state an the name of a village and writes the agents and resources to disk

Usage
data_writer$write(state, village_name)
Arguments
state

The village's village_state that's being written

village_name

The name of the village. This is used to create the data directory

Returns

None


Method clone()

The objects of this class are cloneable with this method.

Usage
data_writer$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


[Package villager version 2.0.0 Index]