balancedSplit function

Split a dataset into training and testing sets, balancing a factor