The problem is that all the main functions use INT instead of LONG to generate R objects. For example, your error message comes from array.c in / src / main
if ((double)nr * (double)nc > INT_MAX)
error(_("too many elements specified"));
where nr and nc are the integers generated earlier for the number of rows and columns of your matrix:
nr = asInteger(snr);
nc = asInteger(snc);
, , LONG, , array.c, , . , , , . , R 3.x , , , ...