Announcement

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

  • New Stata command save2rda

    A new user-written command save2rda is currently available [as beta] here:
    http://www.radyakin.org/transfer/save2rda/

    save2rda allows Stata to export its dataset in the form of an R-workspace, which can be opened by R directly.

    Should you notice any problem, kindly notify me.

    Best, Sergiy Radyakin

  • #2
    Sergiy Radyakin Cool stuff. Out of curiosity, where did you find the file specs for .Rdata files?

    Comment


    • #3
      I have just two questions:

      Is it possible to "save" automatically in R's working directory (I gather the "save" option here will only save in Stata's working directory)?

      What are the advantages of save2rda (apart from saving as .Rdata directly from Stata), if compared to the command when using RStudio and clicking on "import from Stata"?

      To end, it's great that, according to the help files, it preserves Stata's value labels as well as variable labels.
      Best regards,

      Marcos

      Comment


      • #4
        wbuchanan the format was deduced by observing multiple example files collected over the internet, and observing the reactions of R to modifications in the input. This has proven to be simpler than studying the R-source codes.

        Marcos Almeida the command will save to wherever you specify in the path. (I am sorry for not including an example with a full path into the documentation). As per Stata's convention files are saved into Stata's current (working) directory, not working directory of some other application, when the exact path is omitted. You can save to "C:\Users\MAlmeida\Documents\RData\" or whichever else is the directory you want. I don't see any special setting for the R's working directory - when I open the Workspace image the dialog simply suggests the same folder where I left it (where I opened the last workspace file). GUI preferences dialog also doesn't list any special folder.

        The only thing that is reasonable is the result of getwd() in R, which in my case points to "C:/Users/Sergiy/Documents", so this can be obtained from the USERPROFILE environment variable:
        Code:
        display `"`:environment USERPROFILE'"'
        if this is what you mean, then just supply this macro evaluation before the actual filename. At the same time I don't understand what benefit it would have, since the R working directory can easily be changed with setwd(). More importantly R may be absent on the producing machine all together (there is no dependency on R).

        On the second question - it is up to the user to decide. But the most principal difference is that if Stata 15 comes with yet another format change (and there is still room for improvement) then R will stop importing those version files until its source is modified to support this change. With save2rda there should be no such problem (as long as the fundamentals are stable). I am also not quite sure what "import from Stata is doing", perhaps an experienced R-user can conduct the corresponding comparison.

        If there is anything that is expected by the R-users that such an import should do and save2rda is not doing, I would be delighted to hear. Also please note that while R is free, RStudio is not free for everyone, since they have "A commercial license for organizations not able to use AGPL software" as listed here: https://www.rstudio.com/products/RStudio/ I am not sure how much of the Stata import is available to R-users directly without RStudio.

        Interested users may also compare with Stat/Transfer. I guess it is trying to do something fancy with the Unicode conversions, but I couldn't quite figure out what exactly. Perhaps someone can provide more info.

        Best, Sergiy Radyakin

        Comment


        • #5
          Sergiy Radyakin Thank you very much for your clarifying reply.
          Best regards,

          Marcos

          Comment

          Working...
          X