added R function