Wednesday, November 2, 2011

First thoughts on R

Having worked just a little with R, I have some first impressions to share.  I'll give you some links to resources I found helpful with writing the previous project.

First, the documentation is not very good.  I struggled on previous attempts to figure things out.  I still find it crap shoot when I Google, looking for an answer.  Luckily I found a book with a good primer on things.

Second, really, is an acceptable variable name?!?  For the longest time I thought I was missing something looking at examples until I realized that "bar" was not a property on an object "foo." is just a variable/object name and if you have another object named "foo" the two are not related.  Still makes my head hurt.

2.5 -- I can access properties on an object with $.  Seems like an odd choice.

6 Data frames are neat.  This took me longer to understand because of #2 than it should have.  To me, it really looks like a hash object containing arrays of equal length.  It helped to to think of them as plain "object" types from Actionscript -- accessing columns in multiple ways like DF$column, or DF[,"column"] is very similar to or obj["property"] is AS.

5  I still don't understand the mechanics behind the scenes though.  Why when I accessed properties in the Time Series object did I have to use obj[,"property"] instead of obj$property? When I look at the structure (str() function -- I like) the types are different.  Something is going on, but I don't know what.

5.1 How does scoping work with variables in functions? If I don't delete variables inside the function, do they get garbage collected?

6  Many ways to do things.  The two packages I used relied on 2 different types of time series collections.  That threw me for a loop.  Luckily I got it to work.  In one iteration of code I was casting things back and forth using the as.<type>() functions.

7 head() and str() functions are great.  Wish I knew about them when I started.  I saw them in some examples about half way though the project.

8 R needs better default output and publishing tools.  I can easily get information overload from SAS and have it in nicely formatted HTML, PDF, RTF, XML, Excel, etc.  I would love to see an equivalent in R.

Well, I ranted enough on that.

Here is the honor roll of helpful resources:

  1. Option Pricing and Estimation of Financial Models with R  Stefano M Iacus.  I actually ready this cover to cover on my plane trip last week.  The appendix was the most helpful tool I had for the project.
  2. Time Series Analysis with R -Part I, Walter Zucchini, Oleg Nenadi´c.  I need to reread this free PDF.  I skimmed it and it's examples helped me learn how charting works.
  3. Producing Simple Graphs with R Frank McCown.  Another helpful site for graphics.
  4. Quick-R.  Excepts from the book R in Action.  I plan on buying this in the near future.
  5. I also have The R Book by Michael J. Crawley.  The sheer size of this is daunting, but I am hoping that it will become a go to resource (and maybe answer some of my questions).  It didn't make the trip with me because of it's size.

No comments:

Post a Comment