add R files -- draft 2 version