.R file for Plot 2