R implementation of MAGENTA