4 Summarizing Simulation Results

4.1 Tables and Figures

For plotting simulation results:

  • ggplot2 (Wickham, Chang, et al. 2019)
  • lattice (Sarkar 2018)
  • plotly (Sievert et al. 2020)

For making tables with simulation results:

4.2 Exporting the Results

I recommend exporting all the simulation results if:

  • writing all the results into a file would not take a lot of space in the computer
  • existing computations are heavy and thus it is hard to summarize the results right away
  • it is likely that the simulation may be interrupted for some reason

Regardless what we decide to save (either all output or the summarized output), a nice way to save the results is to place a write function inside the loop. Using the nested foreach loops as an example, we will first create an empty .csv file called “results.csv”:

Then, we modify our code in a way that we will not save the results and instead write them into the results.csv file.

References

Sarkar, Deepayan. 2018. Lattice: Trellis Graphics for R. https://CRAN.R-project.org/package=lattice.

Sievert, Carson, Chris Parmer, Toby Hocking, Scott Chamberlain, Karthik Ram, Marianne Corvellec, and Pedro Despouy. 2020. Plotly: Create Interactive Web Graphics via ’Plotly.js’. https://CRAN.R-project.org/package=plotly.

Wickham, Hadley, Winston Chang, Lionel Henry, Thomas Lin Pedersen, Kohske Takahashi, Claus Wilke, Kara Woo, and Hiroaki Yutani. 2019. Ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics. https://CRAN.R-project.org/package=ggplot2.