changed R function

changed R function