The probability of a Type II error is typically noted as $\beta$. The probability of a Type II error where $H_0: \mu = \mu_0$ and $H_1: \mu = \mu_1$ and $\mu_0 < \mu_1$ is given as $\beta = P \Big (\bar X \le \mu_0 + z_{\alpha} \sqrt{\frac{\sigma^2}{n}} ; \mu_1\Big )$ Note that $\bar X \sim N(\mu_1, \sigma^2/n)$. Standardizing to a standard normal we get $\displaylines{ \begin{align} \beta &= P \Big (\frac{\bar X - \mu_1}{\sqrt{\sigma^2/n}} \le \frac{\mu_0 + z_{\alpha} \sqrt{\frac{\sigma^2}{n}} - \mu_1}{\sqrt{\sigma^2/n}} \Big ) \\ &= P \Big (Z \le \frac{\mu_0 + z_{\alpha} \sqrt{\frac{\sigma^2}{n}} - \mu_1}{\sqrt{\sigma^2/n}} \Big ) \end{align} }$ The right side of the inequality includes all fixed and known numbers for an existing sample. You can use `qnorm` to find the probability that Z is less than any given number.