R scripts transferred from the Matlab/Octave code