The shared reproducible example suggests that you have the columns as factors. We need to convert them to numeric first.
We can try with base R ave
. Finding out the max in each group.
x$max.per.group <- ave(x$replicate, x$group, FUN = function(x) max(as.numeric(x)))
# group replicate max.per.group
#1 A 1 5
#2 A 2 5
#3 A 3 5
#4 A 4 5
#5 A 5 5
#6 B 1 2
#7 B 2 2
#8 C 1 3
#9 C 2 3
#10 C 3 3
Another option with dplyr
library(dplyr)
x %>%
group_by(group) %>%
mutate(max.per.group = max(as.numeric(replicate)))