Learn R Programming

pointblank (version 0.5.2)

set_read_fn: Set a table-reading function to an agent

Description

A table-reading function can be associated with an agent with set_read_fn(). If a data table is already associated with an agent, it will act as the target table (i.e., the agent will disregard the table-reading function). However, if there is no data table associated with the agent then the table-reading function will be invoked. We can always remove a data table associated with an agent with the remove_tbl() function. There are two ways to specify a read_fn: (1) using a function (e.g., function() { <table reading code> }) or, (2) with an R formula expression (e.g., ~ { <table reading code> }).

Usage

set_read_fn(agent, read_fn)

Arguments

agent

An agent object of class ptblank_agent that is created with create_agent().

read_fn

A function that's used for reading in the data. If a table is not associated with the agent then this function will be invoked. Should both a tbl and a read_fn be associated with the agent, the tbl will take priority. There are two ways to specify a read_fn: (1) using a function (e.g., function() { <table reading code> }) or, (2) with an R formula expression (e.g., ~ { <table reading code> }).