1.4 Packages

We will be mainly be using the forecast (Hyndman et al. 2020) and tseries (Trapletti and Hornik 2019) packages, with the MARSS (Holmes et al. 2020) package to implement ARMAX models. However we will also use a variety of other packages especially for the multivariate regression chapter. So that you can keep track of what package a function come from, I will use the :: notation for functions that are not from the following standard packages:

  • base R
  • stats
  • ggplot2

Thus to call function fun1 from package pack1, I will use pack1::fun1(). This will make the code more verbose but you will be able to keep track of which function comes from what package.

To install the data used in this book along with all the needed packages, install the FishForecast package from GitHub. If you are on a Windows machine, you will need to install Rtools in order to install packages from GitHub.

To install a package from GitHub, install the devtools package and then run

library(devtools)
devtools::install_github("Fish-Forecast/FishForecast")

Calling

library(FishForecast)

will then make the data objects available.

tidyverse and piping

I will minimize the use of tidyverse and piping. Although the latter can create much more concise code, for beginner R users and programmers, I think it will interfere with learning. I may add the piped versions of the code later. I am not going to be doing much ‘data-wrangling’. I will assume that your data are in the tidyverse format, though I will not be using tibbles explicitly. Our data are quite simple, so this is not hard. See the chapter on inputting your data.

plotting packages

I will use a combination of base plotting and ggplot2 (Wickham et al. 2020) plotting. Doing a tutorial on basic plotting with ggplot2 may be helpful for the material.