r code for this research