Revised R scripts

Revised R scripts