added R plotting code