I am trying to fix my code. I am not sure what I am doing wrong, but the code is supposed to retrieve all values from vector x that are:
- larger than two standard deviations from the average
or
- smaller than two standard deviations from the average.
set.seed(2) x = rnorm(10000) average = mean(x) upper_bound = average + sd(average) lower_bound = average - sd(average) boolean_vector = x < lower_bound | x > upper_bound y = x[boolean_vector]
sd(x)instead ofsd(average).