From 89d58eba518930ed600253f241b2020677f68c46 Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Mon, 19 Oct 2020 20:29:33 +0900 Subject: [PATCH 1/2] Update 03-programming.Rmd --- 03-programming.Rmd | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/03-programming.Rmd b/03-programming.Rmd index bc54aa9..8ce4a3d 100644 --- a/03-programming.Rmd +++ b/03-programming.Rmd @@ -657,24 +657,7 @@ 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 - -``` -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") -``` +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. 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. From 8ad2dad4e5cba5475b4894d1944d3ec99d0ce9f2 Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Mon, 19 Oct 2020 20:38:38 +0900 Subject: [PATCH 2/2] Update 03-programming.Rmd --- 03-programming.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/03-programming.Rmd b/03-programming.Rmd index 8ce4a3d..e040c92 100644 --- a/03-programming.Rmd +++ b/03-programming.Rmd @@ -659,7 +659,7 @@ local(source("code/03-programming_f4.R", local = TRUE)) 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. -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.