R functions created by myself