Very thanks to TopGeek and Capital of Statistics given this R lecture, as part of Seven Languages in Seven Weeks, the R language is more unique than the original Pragmatic book language Prolog.
- Use matrix if possible
- Using functional programming style, only use parameter as data in function body
- Do not using global variable
- Do not using S4 (at least as begineer..)
- Use sapply as a map-reduce style
- Use data.frame rather than matrix as data.frame support more different type.
- Use sqldf to select the data.frame
- is.na() can detect NA as default value.
- is.null() can detect NULL as empty value.
- as.numberic() can convert any type to number type.
- setwd(“D:\git”), setting working directory.
- Keep control flow in program as simple as possible, e.g. only use if and for
- set.seed(1) to have a determined start of random number
Some package recommand: