I'm very new both to this platform and to R, but here is a question I need help with. Suppose you have the following data frame:
ex <- rnorm(10, 3, 1.4)
ei <- rep(1:5, times=2)
eg <- rep(letters[1:2], each=5)
eg.df <- data.frame(eg, ex, ei)
The following code summarizes maximum values of 'ex' and 'ei' in the data frame by group:
eg.df <- eg.df%>% group_by(eg)%>%
mutate(Xmax=max(ex), Imax=ei[which.max(ex)])
and the following one is my 'crude' attempt at finding the group standard deviation for the bootstrapped values of 'ex' (which seems to work fine):
eg.df%>% group_by(eg)%>% summarise(sdEx=sd(rep(sample(max(rep(sample(ex, replace = T), 100)), replace=T), 100)))
Now, my challenge is how to obtain the corresponding value for the 'ei' (or sdEi)--the standard deviation for the bootstrapped values of 'ei' at which 'ex' was maximum.
I'm totally at a loss as to how to approach it. I would appreciate your help. Many thanks in advance!