Sunday, June 8, 2014

How to write and debug an R function


3 comments:

  1. I think tryCatch() is also a good one.

    ReplyDelete
  2. I use both Stata and R. It is not true that "the language for ado files is different than regular Stata language". It is exactly the same language that is used in .do and .ado files. The Stata equivalent of R function is a "program" (a piece of code that you start with "program ..." and finish with "end"). You don't even have to put your program code in an .ado file. You can create "temporary" commands on the fly in your .do file. You just usually use local macros a bit more intensively in programs.

    ReplyDelete
    Replies
    1. Thanks Aleksander. I guess I was maybe thinking of mata. Anyway, I revised the intro to the post.

      Delete