R Code for Plot 1