If it can integrate via a java action or api such as rest, soap, jdbc, flat file, message bus, you can use it in Mendix.
https://www.mendix.com/evaluation-guide/app-capabilities/integration-overview
Short answer is no. Mendix runs on Java and it is not possible to add R code to a java runtime. You can look at java libraries for machine learning such as weka https://www.cs.waikato.ac.nz/ml/weka/
Have a look at this blogpost for some ideas
https://www.mendix.com/blog/using-r-to-gain-insight-from-the-data-in-your-mendix-applications/
This article might be useful: https://ubiops.com/building-a-low-code-app-powered-by-ai/
It shows to deploy your R model in UbiOps and turn it in a webservice which you can then call from your Mendix app.
Also works for Python code.