standard error of sample mean I am asked to calculate the standard error of the sample mean using bootstrapping for this data set
y = c(4.9, 3.3, 2.2, 2.3, 1.6, 2.4, 4.7, 1.4, 1.7, 5.1) 

The solutions are as follows:
set.seed(12345)

nsim = 10^6 
ybar.sim = numeric(nsim)

for (i in 1:nsim){
  y.sim = sample(y, replace=TRUE)
  ybar.sim[i] = mean(y.sim) 
}

se.boot = sd(ybar.sim); se.boot

[1] 0.4322378

whereas I thought it would be this way:
mean(replicate(1000000, sd(sample(
  y, replace=TRUE))/sqrt(length(y))))

which gives [1] 0.4264217
and using the boot library gives:
bootmean <- function(d, i) mean(d[i])
bs <- boot(y, bootmean, R=1000000, stype="i")
print(bs)

Bootstrap Statistics :
    original     bias    std. error
t1*     2.96 0.00021043   0.4318501

which is similar to the first answer.
I do not understand why the first answer is correct given the formula for standard error is the standard deviation divided by the length of the vector. Why is the second answer wrong?

The problem is that your second approach is not estimating the thing you want to be estimating, i.e. $\mathrm{SD}(\bar y)$. You should instead use
> set.seed(1)
> sd(replicate(1000000, mean(sample(y, replace=TRUE))))
[1] 0.4323913

which gives an answer that is within the simulation variability of your other approaches.
To use the bootstrap here, you need to (i) create the bootstrap sample, (ii) calculate the statistic whose distribution you are trying to learn about (the mean in this case), (iii) calculate the empiric standard deviation of that statistic.
