R Code for GZ Quench project