I would like to use R to create a new column in my dataset that includes a maximum for each unique group. My data look like this:
group<-c("A","A","A","A","A","B","B","C","C","C")
replicate<-c(1,2,3,4,5,1,2,1,2,3)
x<-data.frame(cbind(group,replicate))
I'd like to create the third column as shown below - the maximum for each group.
group replicate max.per.group
A 1 5
A 2 5
A 3 5
A 4 5
A 5 5
B 1 2
B 2 2
C 1 3
C 2 3
C 3 3