R Code for SNA project