| Type: | Package |
| Title: | Plotting Methods for 'simmer' |
| Version: | 0.1.19 |
| Description: | A set of plotting methods for 'simmer' trajectories and simulations. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| URL: | https://r-simmer.org,https://github.com/r-simmer/simmer.plot |
| BugReports: | https://github.com/r-simmer/simmer.plot/issues |
| Depends: | R (≥ 3.1.2), simmer (≥ 3.6.0), ggplot2 (≥ 3.0.0) |
| Imports: | DiagrammeR (≥ 1.0.0), dplyr (≥ 0.7.0), tidyr (≥ 0.7.0),scales, utils |
| Suggests: | testthat, knitr, rmarkdown |
| RoxygenNote: | 7.3.2 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2025-07-21 16:12:56 UTC; iucar |
| Author: | Iñaki Ucar |
| Maintainer: | Iñaki Ucar <iucar@fedoraproject.org> |
| Repository: | CRAN |
| Date/Publication: | 2025-07-21 16:41:35 UTC |
simmer.plot: Plotting Methods forsimmer
Description
A set of plotting methods forsimmer trajectories and simulations.
Author(s)
Iñaki Ucar, Bart Smeets
See Also
simmer's homepagehttps://r-simmer.org andGitHub repositoryhttps://github.com/r-simmer/simmer.plot.
Monitoring Statistics
Description
Replacements forget_mon_arrivals,get_mon_attributes andget_mon_resources.These versions just add a new class (arrivals,attributes orresources respectively) to the resulting data frame.
Usage
get_mon_arrivals(...)get_mon_attributes(...)get_mon_resources(...)Arguments
... | see |
Value
Returns a data frame of classarrivals,attributes orresources.
Plot Methods forsimmer Monitoring Statistics
Description
Methods for theplot generic. See below for details about eachmetric available.
Usage
## S3 method for class 'arrivals'plot(x, metric = c("activity_time", "waiting_time", "flow_time"), ...)## S3 method for class 'attributes'plot(x, metric = NULL, keys, ...)## S3 method for class 'resources'plot(x, metric = c("usage", "utilization"), names, items = c("queue", "server", "system"), steps = FALSE, limits = TRUE, ...)Arguments
x | a data frame of class |
metric | specific metric to compute. |
... | unused. |
keys | attributes to plot (if left empty, all attributes are shown). |
names | resources to plot (if left empty, all resources are shown). |
items | ( |
steps | ( |
limits | ( |
Details
The S3 method for 'arrivals' provides three metrics:"activity_time","waiting_time", and"flow_time". The"activity_time" isthe amount of time spent in active state (i.e., intimeout activities),and it is already provided in the output ofget_mon_arrivals. The"flow_time" is the amount of time spent in the system, and it iscomputed as follows:flow = end_time - start_time. Finally, the"waiting_time" is the amount of time spent waiting (e.g., in resources'queues, or due to await activity...), and it is computed as follows:waiting_time = flow_time - activity_time. This method does not applyany summary, but just shows a line plot of the values throughout the simulation.
The S3 method for 'attributes' does not support any metric. It simplyshows a stairstep graph of the values throughout the simulation for the keysprovided (or all the collected attributes if no key is provided).
The S3 method for 'resources' provides two metrics:"usage"and"utilization". The"usage" metric shows a line graph ofthe cumulative average resource usage throughout the simulation, for eachresource, replication and item (by default, queue, server and system, whichis the sum of queue and server). Ifsteps=TRUE, a stairstep graph withthe instantaneous values is provided instead. The"utilization" metricshows a bar plot of the average resource utilization (total time in usedivided by the total simulation time). For multiple replications, the barrepresents the median, and the error bars represent the quartiles. Thus, ifa single replication is provided, the bar and the error bar coincide.
Value
Returns a ggplot2 object.
Examples
t0 <- trajectory("my trajectory") %>% ## add an intake activity seize("nurse", 1) %>% timeout(function() rnorm(1, 15)) %>% release("nurse", 1) %>% ## add a consultation activity seize("doctor", 1) %>% timeout(function() rnorm(1, 20)) %>% release("doctor", 1) %>% ## add a planning activity seize("administration", 1) %>% timeout(function() rnorm(1, 5)) %>% release("administration", 1)env <- simmer("SuperDuperSim") %>% add_resource("nurse", 1) %>% add_resource("doctor", 2) %>% add_resource("administration", 1) %>% add_generator("patient", t0, function() rnorm(1, 10, 2)) %>% run(until=80)resources <- get_mon_resources(env)arrivals <- get_mon_arrivals(env)plot(resources, metric="usage", "doctor", items = "server", steps = TRUE)plot(resources, metric="utilization", c("nurse", "doctor", "administration"))plot(arrivals, metric="waiting_time")Plot Method fortrajectory Objects
Description
A method for theplot generic that plots a diagram of the given trajectory.
Usage
## S3 method for class 'trajectory'plot(x, engine = "dot", fill = scales::brewer_pal("qual"), verbose = FALSE, ...)Arguments
x | a simmer trajectory. |
engine | a string specifying a layout engine (see |
fill | discrete color palette for resource identification. |
verbose | show additional info directly in the labels. |
... | additional parameters for |
Value
Returns anhtmlwidget.
Examples
x <- trajectory() %>% seize("res", 1) %>% timeout(1) %>% release("res", 1) %>% rollback(3)plot(x)