Edwin's R Code