move R to separate file, changes to document