I want to calculate the standard deviation in R. But the standard function "sd(x)" is not the function that I need. I'm looking for a function to calculate the sd(x, in dependency of another variable in my dataframe). So that I can add a new column with the sd by the dependency variable (image). Like this:
image answer sd
a 1 0,70
a 2 0,70
b 2 2,12
b 5 2,12