Useful financial analysis functions in R