Finished R coding