前言

荃者所以在鱼,得鱼而忘荃;蹄者所以在兔;得兔而忘蹄;言者所以在意,得意而忘言。吾安得夫忘言之人而与之言哉!
— 摘自 《庄子·杂篇·物》

The fish trap exists because of the fish; once you’ve gotten the fish, you can forget the trap. The rabbit snare exists because of the rabbit; once you’ve gotten the rabbit, you can forget the snare. Words exist because of meaning; once you’ve gotten the meaning, you can forget the words. Where can I find a man who has forgotten words so I can have a word with him ?1
— Chuang Tzu

  1. 把平时遇到的问题分类汇总形成一本笔记,用以时常查看和更新。
  2. 网罗精美的案例,学习之,应用之
  3. 挑选感兴趣的新技能,钻研之
  4. 学习心得和体会,尤其是那些年的淌坑经历
  5. 从使用者到开发者蜕变,先啃一下 Hadley Wickham 的几本书:
  6. 要写书搭网站,先看一下 Yihui Xie 的书

推荐没事多翻翻官网 FAQ 文档 以及6本自带的手册

  • An Introduction to R (R-intro) includes information on data types, programming elements, statistical modeling and graphics. This document is based on the Notes on S-PLUS by Bill Venables and David Smith.
    • 介绍数据类型,编程基础,统计模型和图形
  • Writing R Extensions (R-exts) currently describes the process of creating R add-on packages, writing R documentation, R’s system and foreign language interfaces, and the R API.
    • 描述创建扩展包、写R包文档的过程,介绍 R 系统,外部语言接口以及 R 的API
  • R Data Import/Export (R-data) is a guide to importing and exporting data to and from R.
    • 从 R 导入和导出数据
  • The R Language Definition (R-lang), a first version of the Kernighan & Ritchie of R, explains evaluation, parsing, object oriented programming, computing on the language, and so forth.
    • 介绍 R 语言程序设计,解释计算、解析、面向对象编程以及计算
  • R Installation and Administration (R-admin).
    • R 安装和管理
  • R Internals (R-ints) is a guide to R’s internal structures. (Added in R 2.4.0.)
    • R 内部结构指南

Hadley Wickham 正在写文档介绍 Documentation for R’s internal C API

致谢

虚位以待壮士

Thanks go to all contributers in alphabetical order: .

非常感谢谁谁以及谁谁对我的帮助。

黄湘云
于矿大宝源公寓

结构

第一章:数学符号说明 第二章:基础知识

  • R语言基础、高级技巧

你好,世界。我写了一本书。这本书是这样的,第 3 章介绍了啥啥,第 4 章说了啥啥,然后是啥啥……

后记

这本书是在 RStudio 内用 R Markdown 写的, Git 控制版本, bookdown 组织章节, knitr 将 R Markdown 源文件转化为 Markdown 文件, Pandoc 再将 Markdown 文件转化为 HTML 文档,而要转化为 PDF 文档则另外需要 TinyTeX 发行版2 和来自 rticles (Allaire et al. 2019) 包的模板(一个基于 Pandoc 的 LaTeX 模板,两个美元符号包含的就是变量,变量基本上是 LaTeX 包的设置选项)。这个网站是通过 Travis-CI 把编译结果(即 _book 目录)推送到 Netlify,实现部署。在 Travis-CI 和 Netlify 都与 Github 绑定的情况下,源代码一发生改变就会触发编译和部署,即持续集成和连续部署,你正在阅读的是 2019-08-18 在 Travis 上构建的。

如果编译和部署成功,你会看到一个绿色的指示器,否则指示器显示红色。Build Status

说明

sourceserifpro 设为默认英文字体,inconsolata 用于代码显示,R 包名称在文中以粗体显示,代码块输出用 #> 表示,以区分普通的代码注释 #

我用了两个 R 包编译这本书,分别是 knitr (Xie 2015)bookdown (Xie 2016)。绘图使用的中文字体是思源宋体和思源黑体, showtext 包安装和调用,tikzDevicefontcm 处理其中的数学公式,xkcd 设置漫画手写体风格,以下是我的 R 进程信息:

xfun::session_info(packages = c('rmarkdown','bookdown'))
#> R version 3.6.1 (2017-01-27)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 16.04.6 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:
#>   base64enc_0.1.3 bookdown_0.12   digest_0.6.20   evaluate_0.14  
#>   glue_1.3.1      graphics_3.6.1  grDevices_3.6.1 highr_0.8      
#>   htmltools_0.3.6 jsonlite_1.6    knitr_1.24      magrittr_1.5   
#>   markdown_1.1    methods_3.6.1   mime_0.7        Rcpp_1.0.2     
#>   rmarkdown_1.14  stats_3.6.1     stringi_1.4.3   stringr_1.4.0  
#>   tinytex_0.15    tools_3.6.1     utils_3.6.1     xfun_0.8       
#>   yaml_2.2.0     
#> 
#> Pandoc version: 2.7.2
# rstan::stan_version()
# blogdown::hugo_version()
cat(system("xelatex -v", intern = TRUE), sep = "\n")
#> XeTeX 3.14159265-2.6-0.999991 (TeX Live 2019)
#> kpathsea version 6.3.1
#> Copyright 2019 SIL International, Jonathan Kew and Khaled Hosny.
#> There is NO warranty.  Redistribution of this software is
#> covered by the terms of both the XeTeX copyright and
#> the Lesser GNU General Public License.
#> For more information about these matters, see the file
#> named COPYING and the XeTeX source.
#> Primary author of XeTeX: Jonathan Kew.
#> Compiled with ICU version 63.1; using 63.1
#> Compiled with zlib version 1.2.11; using 1.2.11
#> Compiled with FreeType2 version 2.9.1; using 2.9.1
#> Compiled with Graphite2 version 1.3.13; using 1.3.13
#> Compiled with HarfBuzz version 2.3.1; using 2.3.1
#> Compiled with libpng version 1.6.36; using 1.6.36
#> Compiled with poppler version 0.68.0
#> Compiled with fontconfig version 2.11.0; using 2.11.94
cat(system2("gcc", args = "-v", stderr = TRUE, stdout = TRUE), sep = "\n")
#> Using built-in specs.
#> COLLECT_GCC=gcc
#> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
#> Target: x86_64-linux-gnu
#> Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.11' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
#> Thread model: posix
#> gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)
cat(system2("g++", args = "-v", stderr = TRUE, stdout = TRUE), sep = "\n")
#> Using built-in specs.
#> COLLECT_GCC=g++
#> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
#> Target: x86_64-linux-gnu
#> Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.11' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
#> Thread model: posix
#> gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)

授权

本书采用 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 许可,请君自重,别没事儿拿去传个什么新浪爱问、百度文库以及 XX 经济论坛,项目中代码使用 MIT 协议 开源

参考文献

Allaire, JJ, Yihui Xie, R Foundation, Hadley Wickham, Journal of Statistical Software, Ramnath Vaidyanathan, Association for Computing Machinery, et al. 2019. Rticles: Article Formats for R Markdown. https://CRAN.R-project.org/package=rticles.

Xie, Yihui. 2015. Dynamic Documents with R and Knitr. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. http://yihui.name/knitr/.

Xie, Yihui. 2016. Bookdown: Authoring Books and Technical Documents with R Markdown. Boca Raton, Florida: Chapman; Hall/CRC. https://github.com/rstudio/bookdown.