added database manipulation R functions