欢迎
Book in early development. Planned release in 202X.
如何发问
The phrase “does not work” is not very helpful, it can mean quite a few things including:
- Your computer exploded.
- No explosion, but smoke is pouring out the back and microsoft’s “NoSmoke” utility is not compatible with your power supply.
- The computer stopped working.
- The computer sits around on the couch all day eating chips and watching talk shows.
- The computer has started picketing your house shouting catchy slogans and demanding better working conditions and an increase in memory.
- Everything went dark and you cannot check the cables on the back of the computer because the lights are off due to the power outage.
- R crashed, but the other programs are still working.
- R gave an error message and stopped processing your code after running for a while.
- R gave an error message without running any of your code (and is waiting for your next command).
- R is still running your code and the time has exceeded your patience so you think it has hung.
- R completed and returned a result, but also gave warnings.
- R completed your command, but gave an incorrect answer.
- R completed your command but the answer is different from what you expect (but is correct according to the documentation).
There are probably others. Running your code I think the answer is the last one.
— Greg Snow 1
R 社区提供了丰富的帮助资源,可以在 R 官网搜集的高频问题 https://cran.r-project.org/faqs.html 中查找,也可在线搜索 https://cran.r-project.org/search.html 或 https://rseek.org/ ,更多获取帮助方式见 https://www.r-project.org/help.html。爆栈网问题以标签分类,比如 r-plotly、r-markdown、 data.table 和 ggplot2,还可以关注一些活跃的社区大佬,比如 谢益辉。
运行信息
本书 R Markdown 源文件托管在 Github 仓库里,本地使用 RStudio IDE 编辑,bookdown 组织各个章节的 Rmd 文件和输出格式,使用 Git 进行版本控制。每次提交修改到 Github 上都会触发 Travis 自动编译书籍,将一系列 Rmd 文件经 knitr 调用 R 解释器执行里面的代码块,并将输出结果返回,Pandoc 将 Rmd 文件转化为 md 、 html 或者 tex 文件。若想输出 pdf 文件,还需要准备 TeX 排版环境,最后使用 Netlify 托管书籍网站,和 Travis 一起实现连续部署,使得每次修改都会同步到网站。最近一次编译时间 2023年03月01日23时13分06秒,本书用 R version 4.2.0 (2022-04-22) 编译,完整运行环境如下:
xfun::session_info(packages = c(
"knitr", "rmarkdown", "bookdown"
), dependencies = FALSE)
## R version 4.2.0 (2022-04-22)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.5 LTS
##
## Locale:
## LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## LC_PAPER=en_US.UTF-8 LC_NAME=C
## LC_ADDRESS=C LC_TELEPHONE=C
## LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## Package version:
## bookdown_0.26 knitr_1.39 rmarkdown_2.14
##
## Pandoc version: 2.16.2
借助 bookdown [1] 可以将 Rmd 文件组织起来, rmarkdown [2]和 knitr [3] 将源文件编译成 Markdown 文件, Pandoc 将 Markdown 文件转化成 HTML 和 TeX 文件, TinyTeX [4] 可以将 TeX 文件进一步编译成 PDF 文档,书中大量的图形在用 ggplot2 包制作 [5],而统计理论相关的示意图用 Base R 创作。
记号约定
正文中的代码、函数、参数及参数值以等宽正体表示,如 data(list = c('iris', 'BOD'))
,
其中函数名称 data()
,参数及参数值 list = c('iris', 'BOD')
,R 程序包用粗体表示,如 graphics。