Sample Size & Power

Sample size and power analysis in R β€” power.t.test() for t-tests and the pwr package for standardised effect sizes and proportions.

Plan the study before you collect the data.

Run the code

Everything in the video β€” edit it and press Run Code to run real R right here, or copy it:

Note

The first Run Code installs the packages this lesson needs (pwr) into your browser session β€” give it 20–40 seconds.

Download this R script  Β·  β–Ά Open the full playground

When to use it. Compute the sample size you need for a target power, or the power you’d have at a given n. Do it at the design stage, not after the results are in.

Try the sample size & power calculator Β· read power analysis before you have data.