add cookbook and fix R code