added ability to input a pre-existing data.frame