Hi there - I am new to R. It might be very simple but I need help.

Group and value are given, and I want to add one more variable called "max_value" which indicates the maximum value of each group.

I tried...

data[, max_value := max(value), by = group]

but the result does not seem to be correct.

Group value **max_value**

A 3 3

A 1 3

A 2 3

B 3 6

B 6 6

B 2 6

C 4 10

C 1 10

C 10 10

Thank you in advance.