A reaction in which atoms of an element replace the atoms of a second element in a compound.