Adding plot functionality to R script