Codes for R programming