0

I am already familiar with the possibility to "call" some R functions from python, but what I'm looking for is a way to convert R code to Python code.

I doubt that there's an automatic way to do it '^^ (I know that it's possible to convert java code into Kotlin code automatically, but it's not perfect '^^ and I doubt that there is a way for R to Python) But if you know one I'm all ears!

What I want is to know if there is a "strategy" or a good way to go about it and convert a code from one language to another. Like, is it better to spend two weeks reading the code entirely until I know it by heart, or is it better to just start and copy/convert/paste line by line?

I do have some experience doing this type of project, as I recoded a Python code into Kotlin code, but it took way more time than I had.

this project is on the span of an internship of 2 months, so my time is rather limited, and the program I'm working on is on the subject of hydrology, which I don't know a thing about !


TL;DR

I want to know if you have a method to convert code from one language to another (here R to Python) or at least, if you have a way to estimate the time it might take me.

KDlotusk
  • 1
  • 1
  • I understand you want to convert R -> python and already you have python code that calls R code. 0) Always run as much tests as you can. 1) Write unit tests. I am not a big of of UT but here they can be a life saver. 2) Move R functionalities slowly to python. And run tests. – Melon May 13 '22 at 11:07
  • 1
    thanks! that's actually quite good advice! I tend to forget to test while coding and I usually have to change everything at the end – KDlotusk May 13 '22 at 12:06
  • Is there a specific reason for the conversion from R to python? In any case, as it seems you are dealing with some sort of data science, I recommend the book "Python and R for the Modern Data Scientist" which provides an introduction to both languages underlying principles and strength. The answer also depends if you are the author of the code base or not, and your current and desired mastery of both languages. – hrvg May 13 '22 at 17:24

0 Answers0