Some enhancements

Some enhancements to R script and CodeBook