General data mining R code