create aggregate column based on variables with R [duplicate]
问题 This question already has answers here : Calculating statistics on subsets of data [duplicate] (3 answers) Closed 3 years ago . I apologize in advanced if this is somewhat of a noob question but I looked in the forum and couldn't find a way to search what I am trying to do. I have a training set and I am trying to find a way to reduce the number of levels I have for my categorical variables (In the example below the category is the state). I would like to map the state to the mean or rate of