added R Code of Step 2