Added ddply ranking function to mess with later. Moved degree code up.