Turn R into function and rename.