Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • converting R code into Stata?

    Is there something out there that could help me convert R code into Stata code? Someone shared with me a piece of R code that I could really use for a paper, but I don't speak R. Is there such a thing as an R-to-Stata code translator? (I think I saw something the other way around, which doesn't help me, sadly)

  • #2
    You may need someone who knows both.

    I don’t know R at all well but my impression is that older R (or S!) code is easier to translate than newer. Some similarities are more than fortuitous in that programmers can be inspired by what they see on their travels. I took some ideas from S in early commands or egen functions I wrote. I suspect that R owes a bit more to Stata than it’s cool to admit in the R world.

    The best ways to find out are to post the code, with no promises.

    Comment


    • #3
      If the code is not too complex, I could give it a try without making any promises. I had/have to translate R-code into Stata-code for my PhD-thesis which did some data preparation tasks.
      If the R-code is not too complex, you can install R and R-studio and then use the help and other tutorials to get a general idea how R works. But for that to work, you need some knowledge of Stata programming and general programming concepts to see the similarities between the R and Stata. It might not be easy but it is doable.
      I am also not aware of a translator from R to Stata. Probably at best a semi-automatic approach might work given that not all R-concepts can be translated 1-to-1 into Stata.
      This is just my experience.

      Comment


      • #4
        These may help.

        https://github.com/EconometricsBySim...ry:-Stata-to-R

        http://www.soc.univ.kiev.ua/sites/de...ion_syntax.pdf
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          There's no harm in posting the R code here and those who are fluent in both may feel inclined to help.

          Comment


          • #6
            Originally posted by Sven-Kristjan Bormann View Post
            If the code is not too complex, I could give it a try without making any promises. I had/have to translate R-code into Stata-code for my PhD-thesis which did some data preparation tasks.
            If the R-code is not too complex, you can install R and R-studio and then use the help and other tutorials to get a general idea how R works. But for that to work, you need some knowledge of Stata programming and general programming concepts to see the similarities between the R and Stata. It might not be easy but it is doable.
            That's exactly what I need it for, the last chapter of my PhD dissertation. I don't think it's too complex, it's just long. I was first inclined to do what you suggested, install R and use help and tutorials, since I do have some level of proficiency with Stata, but it's very time consuming, hence me looking for some degree of automation.
            I will give it a shot like that, though. It's too long to post it here, don't want to abuse the forum, and learning some R could serve me well, but I'll post here the chunks that are giving me a hard time. Thanks for the offer!

            Comment

            Working...
            X