some R functions