R utilities functions