Transform a numeric vector by grouping it according to the values of the supplied factor and then rescaling within the groups.