Is there a way to create relative numbers based on multiple factors without creating multiple subsets of an R data frame?
E.g. in mtcars I want to have the 'hp' relative to the mean hp per 'am' and 'gear'.
I could subset mtcars by am and subsequently gear and create a new column with hp relative to the mean and then rbind all the subsets together again. However, I think this can be done in a more elegant and easier way. Maybe some plyr, but I have not found a solution.