diff --git a/03-programming.Rmd b/03-programming.Rmd index bc54aa9..e040c92 100644 --- a/03-programming.Rmd +++ b/03-programming.Rmd @@ -657,26 +657,9 @@ local(source("code/03-programming_f4.R", local = TRUE)) ### Compiling code -There are a number of ways to compile code. The easiest is to compile individual functions using `cmpfun()`, but this obviously doesn't scale. If you create a package, you can automatically compile the package on installation by adding +There are a number of ways to compile code. The easiest is to compile individual functions using `cmpfun()`, but this obviously doesn't scale. If you create a package, you can automatically compile the package on installation. This is achieved by the `ByteCompile` logical field on the `DESCRIPTION` file, whose default value is `true`. Similarly, all packages are by default byte-compiled on installation since R 3.5.0. -``` -ByteCompile: true -``` - -to the `DESCRIPTION` file. Most R packages installed using `install.packages()` are not compiled. We can enable (or force) packages to be compiled by starting R with the environment variable `R_COMPILE_PKGS` set to a positive integer value and specify that we install the package from `source`, i.e. - -```{r eval=FALSE} -## Windows users will need Rtools -install.packages("ggplot2", type = "source") -``` - -Or if we want to avoid altering the `.Renviron` file, we can specify an additional argument - -```{r eval=FALSE} -install.packages("ggplot2", type = "source", INSTALL_opts = "--byte-compile") -``` - -A final option is to use just-in-time (JIT) compilation. The `enableJIT()` function disables JIT compilation if the argument is `0`. Arguments `1`, `2`, or `3` implement different levels of optimisation. JIT can also be enabled by setting the environment variable `R_ENABLE_JIT`, to one of these values. +A final option is to use just-in-time (JIT) compilation. The `enableJIT()` function disables JIT compilation if the argument is `0`. Arguments `1`, `2`, or `3` implement different levels of optimisation. The defualt level is `3` and can be changed by the environment variable `R_ENABLE_JIT`. ```{block, type="rmdtip"} We recommend setting the compile level to the maximum value of 3.