Best of Both Worlds: R & Python

Nik Agarwal

Prior knowledge:
No previous knowledge expected


Too many data scientists discuss R vs. Python, but completely miss the bigger point: both can be complement each other! The {reticulate} package in R easily allows you to use Python libraries with the R objects you've already created. With {reticulate}, you can now use your favorite Python libraries within R and enjoy the best of both worlds!


The dilemma

  • R vs. Python: seems you have to pick one or the other
  • Deployment typically done in one language; primarily Python or Java
  • Some libraries in Python can be more powerful or easier to use than equivalent R libraries


  • R package that enables interfacing with Python
  • Can use any Python library within R
  • Translates R objects to equivalent Python objects on the fly
  • Used by many R deep learning libraries such as {keras} and {tensorflow}

Key benefits

  • Data scientists familiar with R can continue using R to code, manage scripts, etc. in one IDE
  • Able to use libraries/packages from either language to be more effective/efficient
  • R workflow is maintained (augmented with Python)

My typical workflow

  • Data analysis in R (including acquiring data from database, data wrangling, plotting, etc.)
  • Data modeling in both R & Python (use best libraries/packages from both languages - {tidymodels} & scikit-learn)
  • Deployment of any model is with Docker and using APIs for R & Python models ({plumber} for R & flask for Python)


  • screenshot of R code using Python libraries