add_dataframe: Add a Data Frame

View source: R/simmer-methods.R

add_dataframeR Documentation

Add a Data Frame

Description

Attach a new source of arrivals to a trajectory from a data frame.

Usage

add_dataframe(.env, name_prefix, trajectory, data, mon = 1, batch = 50,
  col_time = "time", time = c("interarrival", "absolute"),
  col_attributes = NULL, col_priority = "priority",
  col_preemptible = col_priority, col_restart = "restart")

Arguments

.env

the simulation environment.

name_prefix

the name prefix of the generated arrivals.

trajectory

the trajectory that the generated arrivals will follow (see trajectory).

data

a data frame with, at least, a column of (inter)arrival times (see details).

mon

whether the simulator must monitor the generated arrivals or not (0 = no monitoring, 1 = simple arrival monitoring, 2 = level 1 + arrival attribute monitoring)

batch

number of arrivals generated at a time. Arrivals are read from the data frame and attached to the trajectory in batches depending on this value. In general, it should not be changed.

col_time

name of the time column in the data frame.

time

type of time column: interarrival, if the time column contains interarrival times, or absolute, if the time column contains absolute arrival times.

col_attributes

vector of names of the attributes columns (see details).

col_priority

name of the priority column.

col_preemptible

name of the preemptible column.

col_restart

name of the restart column.

Details

The data frame provided must have, at least, a column of (inter)arrival times. This method will look for it under the name "time" by default, although this can be changed with the col_time parameter.

If there is any column named col_priority="priority", col_preemptible=priority or col_restart="restart", they will be used to set the prioritization values for each arrival (see add_generator).

If there are additional columns (with col_attributes=NULL, by default), they will be assigned to arrival attributes named after each column name. All these columns must be numeric (or logical). Otherwise, if a vector of column names is specified, only these will be assigned as attributes and the rest of the columns will be ignored.

A value of batch=Inf means that the whole data frame will be attached at the beginning of the simulation. This is not desirable in general, because the performance of the event queue is degraded when it is populated with too many events. On the other hand, a low value results in an increased overhead due to many function calls. The default value has been tested to provide a good trade-off.

Value

Returns the simulation environment.

See Also

Other sources: add_generator.


simmer documentation built on Sept. 28, 2024, 1:07 a.m.