Announcement

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

  • Importing R Files/Packages into Stata

    Does anyone know of a a user-written command that allows one to import R files and/or packages directly into Stata? Thank you.

  • #2
    R files: presumably R in the wide sense is capable of emitting all sorts of files. Specific details would guide answers immensely. In general, the closer a data file is to something like a comma- or tab-separated file, the easier it is to import into Stata.

    R packages: Stata doesn't understand R code in general. There are ways of running R code from Stata if that is what you seek. See rsource from SSC.

    This is unlikely to be a complete answer.

    Comment


    • #3
      Originally posted by Ian Goldsmith View Post
      Does anyone know of a a user-written command that allows one to import R files and/or packages directly into Stata? Thank you.
      With respect to exporting data R package foreign will be of interest to you. With use of the foreign package you can export R data object to Stata data files. With respect to running R code in Stata, it is much easier to do it other way round. Using RStata package will let you run Stata code inside R. Personally, I find that calling R from Stata is more cumbersome (you can have a look at this guide here) as you will have to manipulate number of files whereas RStata will simply enable you to send code to Stata without leaving R, so if you work in nice IDE like RStudio, you will be able to do "everything" through one interface which, personally, I find very convenient.
      Kind regards,
      Konrad
      Version: Stata/IC 13.1

      Comment


      • #4
        Using RStata package will let you run Stata code inside R. Personally, I find that calling R from Stata is more cumbersome (you can have a look at this guide here) as you will have to manipulate number of files whereas RStata will simply enable you to send code to Stata without leaving R, so if you work in nice IDE like RStudio, you will be able to do "everything" through one interface which, personally, I find very convenient.
        If you are interested in Rstata, I think that you should link to this post instead of the previously cited.

        Comment


        • #5
          Please be aware that the old post by Modesto Escobar is obsolete. It refers to an person who thought he was funny doing an April's fool joke.
          RStata is an R package (first version 2015-12-07, i.e. long after Modesto's post), with which you can run Stata code from within R, see here: https://cran.r-project.org/web/packa...ata/RStata.pdf

          RStata is highly recommended.

          Comment

          Working...
          X