Skip to content

Instantly share code, notes, and snippets.

@tmasjc
Created April 13, 2018 04:47
Show Gist options
  • Save tmasjc/08371506a9f56f919839daca4fcffc0f to your computer and use it in GitHub Desktop.
Save tmasjc/08371506a9f56f919839daca4fcffc0f to your computer and use it in GitHub Desktop.
Standard repository structure and style.

Checklist

-	Does the project contain R script?
-	Does the project contain data?
-	Does the project contain a test script?
-	Do the scripts contain proper comments?
-	Is the project organised in proper structure? 
-	Do the scripts follow R style guide?
		http://style.tidyverse.org/
-	Does the README display the project structure?
		tree {repo} | pbcopy

Proper Structure

Every project is a Rproj with its own repo, which contains

README - 描述
	Why is this needed? (目的)
	How it is implemented? (算法、逻辑)
	What does it contain? (文件)
		R/get_data  - 提取数据脚本
		R/eda.R - 探索脚本
		R/main.R - 主要脚本
		R/abc.R - 其他
		...

Extra

  1. On naming script, use verb_result.R
  2. Common methods should be packaged.
  3. EVERY MACHINE LEARNING MODEL IS A PROJECT OF ITSELF. (git submodule)

Sample

Demo
├── Data
│   ├── raw.rdata
│   └── sample.rdata
├── Demo.Rproj
├── Model
│   ├── Data
│   │   ├── sample_1.csv
│   │   └── sample_2.csv
│   ├── Model.Rproj
│   └── R
│       ├── linear_reg.R
│       ├── main.R
│       └── run_test.R
├── R
│   ├── eda.R
│   ├── main.R
│   └── run_test.R
└── README.md

5 directories, 13 files

Useful tips

  1. Reformat code in RStudio ctrl + shift + A
  2. Timestamp ts
  3. Code break cmd + shift + R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment