Implementation of Envelope methods in R