Eric Guo's

in HTML5, JavaScript, Ruby & Rails, Python, and Cloud MES!

The R Language Training Notes


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
  1. Use data.frame rather than matrix as data.frame support more different type.
  2. Use sqldf to select the data.frame
  3. can detect NA as default value.
  4. is.null() can detect NULL as empty value.
  5. as.numberic() can convert any type to number type.
  6. setwd(“D:\git”), setting working directory.
  7. Keep control flow in program as simple as possible, e.g. only use if and for
  8. set.seed(1) to have a determined start of random number
Some package recommand:
  • stringr
  • sqldf
  • RPostgreSQL
  • gdata
  • XLConnect
  • xml
  • Rserve
  • ggplot2