some simple R functions