1. 使用 RMarkdown 的 child 参数,进行文档拼接。
  2. 这样拼接以后的笔记方便复习。
  3. 相关问题提交到 Issue

1 配置

参考 https://stackoverflow.com/questions/32127524/how-to-install-and-use-make-in-windows

Everything 查询 make.exe,发现在 C:\Rtools\bin\make.exe,先配置好环境变量就可以用了。

2 示例

参考 https://github.com/pavopax/gists/blob/master/makefile-quick-start.md

type make data to run your “get data” scripts type make output to only run your “output” script(s) type make all to rerun the entire analysis, which consists of the pieces specified in the first line (data, process, output) all, data, process, output, etc are called “targets”

参考 https://github.com/pavopax/gists/blob/master/assets/makefile-example-1.bash

这是一个模板,其实这个过程可以在 R 里面实现,但是 R 要用其他语言的时候,要用system(),有点麻烦。

https://stat545.com/automation-overview.html

可以参考 https://github.com/JiaxiangBU/learn_rmd/blob/master/Makefile

4 更新 R 项目

直接可以再其他 git bash (RStudio里面的) 就可以更新了。 或者说不需要打开 RStudio 项目直接用 make 去更新。

5 q() 失效

Rscript -e "q(save = 'no')"加在 make 里面没用,因为在 Bash 中,这是新开了一个进程,不影响当前的 RStudio。

6 missing separator

参考 https://blog.csdn.net/u010299133/article/details/83895299

在相应的行前tab键,很多时候可能是加了空格键。

8 单独调用 make 命令测试

一条条测试,这样比较快。 这主要是一个思路问题。

8.1 检查 make 执行结果

 [1] "toc:"                                            
 [2] ""                                                
 [3] "\tRScript analysis/build_toc.R"                  
 [4] ""                                                
 [5] "render:"                                         
 [6] ""                                                
 [7] "\tRScript analysis/build_readme.R"               
 [8] ""                                                
 [9] "clean:"                                          
[10] ""                                                
[11] "\trm README.html"                                
[12] ""                                                
[13] "push:"                                           
[14] "\tgit add ."                                     
[15] "\tgit commit -m 'update, use `push` in Makefile'"
[16] "\tgit push"                                      
[17] ""                                                
[18] "README: toc render clean push"                   
[19] ""                                                
[20] "all: README"                                     
[21] ""                                                
[22] "copy:"                                           
[23] ""                                                
[24] "\tRScript code/copy-md.R"                        

README: toc render clean push先不执行 push,手动执行 make toc render clean 查看结果。

看下目录更新的效果,再选择make push

参考文献