code for the r value analysis