Revised R Code again