Support Options

  • Knowledge Base

    Find information on common questions and issues.

  • Support Messages

    Check on the status of your correspondences with members of the QUBES team.

Contact Us

About you
About the problem

Hardy-Weinberg Equilibrium: a swirl resource

By Abigail E. Cahill

Albion College

Students will use swirl to understand Hardy-Weinberg equilibrium. The lesson starts with observed numbers of individuals for each genotype, and students will work through a number of steps to assess whether or not the population is in equilibrium.

Listed in Teaching Materials | resource by group Make Teaching with R in Undergraduate Biology Less Excruciating 2020

Version 1.0 - published on 14 Jun 2020 doi:10.25334/ZQSM-5S44 - cite this

Licensed under CC Attribution-ShareAlike 4.0 International according to these terms



This lesson will allow students to test a population to see if it meets Hardy Weinberg expectations starting with observed numbers of individuals in each genotype within the population. It will require them to calculate observed allele frequencies, expected genotype frequencies, and use a chi-square test to get (and then interpret) a p-value.

Students should have a basic knowledge of HWE and its equations (p+q=1 and p2+2pq+q2=1) and should know how to assign objects in R.

The lesson was designed as a part of an upper-level Ecological Genetics class, to be completed within a 45-minute class period as a complement to material about HWE.

By the end of this swirl lesson, students will be able to

  1. Test a population for Hardy-Weinberg equilibrium when given observed genotype data (numbers of individuals of each genotype)
  2. Use the chisq.test() function in R and interpret a p-value


Cite this work

Researchers should cite this work as follows:


Make Teaching with R in Undergraduate Biology Less Excruciating 2020

When watching a resource, you will be notified when a new version is released.