R: Function to Create a Unit Object