How to calculate difference between sample and population mean in R I am taking a statistics course focused on R and was asked this question about a normally distributed sample of weights:

Use the CLT to approximate the probability that our sample mean estimate is off by more than 2 grams from the population mean.

The answer was given as:
2 * ( 1-pnorm(2/sd(X) * sqrt(12) ) )

I understand why the value is multiplied by 2 (to estimate for a difference greater than 2 and less than -2), but I don't understand where the rest of the equation was derived from. Can someone explain how this equation is able to answer the above question?
 A: (I probably should put this as a comment, but I'd like to format the equations a bit more precisely.)
The probability of observing a mean of a given sample size $n$ is calculated using the sampling distribution, which is normal with mean $\mu_{\bar{x}}=\mu$ and standard deviation $\sigma_{\bar{x}}=\frac{\sigma}{\sqrt{n}}$. (There are additional requirements here, such as the population distribution needs to be normal, the sample must be randomly drawn, etc.)
So, if we want to find the probability that the sample mean is two more than the population mean, we need to find
$$\begin{align}P(\bar{x} \ge \mu+2) & = P\left( z \ge \frac{(\mu+2)-\mu}{\frac{\sigma}{\sqrt{n}}}\right) \\
& = P\left(z \ge \frac{2\sqrt{n}}{\sigma} \right) \\
& = 1-P\left(z \le \frac{2\sqrt{n}}{\sigma} \right)\\
\end{align}$$
So, based on the answer provided, it appears the sample size for this problem (which wasn't reported by the OP) is $n=12$.
Lastly, as mentioned by the OP, the value is doubled because the same value is obtained for $P(\bar{x} \le \mu -2)$.
Happy to provide clarification as needed.
