Fixed the R calculation