作者:Yihui Xie
译者:郑宝童
日期:2021.06.21


7.A.1 R and R packages

R can be downloaded and installed from any CRAN (the Comprehensive R Archive Network) mirrors, e.g., https://cran.rstudio.com. Please note that there will be a few new releases of R every year, and you may want to upgrade R occasionally.

R 可以从任何 CRAN(the Comprehensive R Archive Network)镜像下载和安装,例如 https://cran.rstudio.com。请注意,每年都会有一些 R 的新版本,您可能希望偶尔升级 R。
To install the bookdown package, you can type this in R:

  1. install.packages("bookdown")

This installs all required R packages. You can also choose to install all optional packages as well, if you do not care too much about whether these packages will actually be used to compile your book (such as htmlwidgets):

这将安装所有必需的 R 包。你也可以选择安装所有可选包,如果你不太关心这些包是否真的会被用来编译你的书(比如 htmlwidgets):

  1. install.packages("bookdown", dependencies = TRUE)

If you want to test the development version of bookdown on GitHub, you need to install devtools first:

如果想在GitHub上测试bookdown的开发版,需要先安装devtools

  1. if (!requireNamespace("devtools")) install.packages("devtools")
  2. devtools::install_github("rstudio/bookdown")

R packages are also often constantly updated on CRAN or GitHub, so you may want to update them once in a while:

R 包也经常在 CRAN 或 GitHub 上不断更新,因此您可能希望不时更新它们:

  1. update.packages(ask = FALSE)

Although it is not required, the RStudio IDE can make a lot of things much easier when you work on R-related projects. The RStudio IDE can be downloaded from https://www.rstudio.com.

尽管不是必需的,但当您处理 R 相关项目时,RStudio IDE 可以使很多事情变得更容易。 RStudio IDE 可以从 https://www.rstudio.com 下载。