modify r code