3
$\begingroup$

I'm new in this field and I started working with data by using R. Because of that, I find R much easier to approach a data project. However, apparently an employer wants you to know an object-oriented programing language (a language like Python).

So it would be smart to think I can use Python just when I need to deal with a complex programming process, like replacing the na's in Titanic/kaggle project with the average based on name and to use R for anything else? So use them both interchangeably?

Beside the fact that Python is more programming oriented I don't see why somebody would use it over R...

$\endgroup$

2 Answers 2

5
$\begingroup$

Several clarifications:

  • you can program with object-oriented (OOP) concepts in R, even though OOP in R has slightly different syntax from other languages. Methods do not bind to objects. In R, different method versions will be involved based on the input argument classes (and types). (Ref: Advanced R)

  • you can also replace nans with mean / any stat. / value in R using a mask if you store the data in a dataframe (See SO post)

  • There is no problem using them interchangeably. I use R from Python using the package RPy2. I assume it is equally easy to do it the other way round.

At the end of the day, any language is only as good as how much the users know about it. Use one that you are more familiar with and try to learn it properly using the vast online resources online.

$\endgroup$
1
  • $\begingroup$ For using Python from R, there's reticulate. $\endgroup$
    – Ben Reiniger
    Apr 21, 2019 at 18:50
0
$\begingroup$

Using org-babel could be a solution. In a single file you can have executable code blocks containing different languages. The caveat is that you have to use emacs and org-mode.

I don't have an example of Python and R together, but I did use Python and Bash for instance in the same document. Note that, I assume you won't be able to share results generated by Python inside R block and vice versa.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.