\begin{Schunk}
\begin{Sinput}
 ## Find power for a given sample size, effect size, and alpha level
 pwr.r.test(n = 30, r = .1, sig.level = .05)
\end{Sinput}
\begin{Soutput}
     approximate correlation power calculation (arctangh transformation) 

              n = 30
              r = 0.1
      sig.level = 0.05
          power = 0.08208191
    alternative = two.sided
\end{Soutput}
\begin{Sinput}
 ## A priori power analysis: Find sample size required for a given
 ## level of power, alpha, and effect size
 pwr.r.test(power = .80, r = .1, sig.level = .05)
\end{Sinput}
\begin{Soutput}
     approximate correlation power calculation (arctangh transformation) 

              n = 781.7516
              r = 0.1
      sig.level = 0.05
          power = 0.8
    alternative = two.sided
\end{Soutput}
\begin{Sinput}
 ## Do the same with Cohen's D for a t test
 pwr.t.test(n = 30, d = .2, sig.level = .05)
\end{Sinput}
\begin{Soutput}
     Two-sample t test power calculation 

              n = 30
              d = 0.2
      sig.level = 0.05
          power = 0.1186794
    alternative = two.sided

NOTE: n is number in *each* group
\end{Soutput}
\begin{Sinput}
 pwr.t.test(power = .80, d = .2, sig.level = .05)
\end{Sinput}
\begin{Soutput}
     Two-sample t test power calculation 

              n = 393.4057
              d = 0.2
      sig.level = 0.05
          power = 0.8
    alternative = two.sided

NOTE: n is number in *each* group
\end{Soutput}
\begin{Sinput}
 ## repeat without the requirement for equal group sizes
 pwr.t2n.test(n1 = 20, n2 = 12, d = .2, sig.level = .05)
\end{Sinput}
\begin{Soutput}
     t test power calculation 

             n1 = 20
             n2 = 12
              d = 0.2
      sig.level = 0.05
          power = 0.08280013
    alternative = two.sided
\end{Soutput}
\begin{Sinput}
 pwr.t2n.test(power = .8, n1 = 40, d = .5, sig.level = .05)
\end{Sinput}
\begin{Soutput}
     t test power calculation 

             n1 = 40
             n2 = 153.0969
              d = 0.5
      sig.level = 0.05
          power = 0.8
    alternative = two.sided
\end{Soutput}
\end{Schunk}
