Here is a link to a paper that I wrote regarding submitting R code to be executed via SAS/IML submit/r block.
HTH,
Ross
https://www.lexjansen.com/sesug/2016/AD-118_Final_PDF.pdf
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.