Friday, August 06, 2010

The more time I spend graphing things in R...

...the more I realize that documentation is amazing.

It has been teh uber useful to me, to put in lightly, to have the awesome "live MatLab helpdesk" also known as "Pericles v 2.0".  From the information in the files he made, as well as the functional file of "logistic", I have been able to see the "patterns" in Matlab language that allow me to write more "sophisticated" (see also: more for loops and more random data) for other programs! Currently the ::name not provided here because it is a very common forestry term and until I'm done with the project I don't want anyone searching it:: series is on it's 9th iteration, each one calculating different data than the last!

I was talking to the coworker the other day about the helplessness of many computer software documentation things.  I think that many people who write those things jump through the basics very quickly. For example, it's great to know how to make sweet looking graphs in R using someone's fancy package, and some people need to learn how to make packages like that, but I will tell you that I used R for almost six months before I was able to understand what a "working directory" was and how to set it. I laugh now because it seems kind of simple to me, but imagine you are someone as I am who comes from a background of humanities. You can do everything in life on Microsoft Word, and you happen to also own a calculator. You jump into a management program to... as I did during my first semester at CU, discover that Excel is actually a valuable part of the office package, too, and that if you are given a process to do in Excel that needs to extend to, say, 2000 cells, with specific row and column references (for example, a constant in the first column is applied via a function to everything else in the row), that yes, there is a way to write this into your first row using fixed cell references and copy paste to the other cells.  Someone, also known as me, did this by hand during Valuation Economics and suffered greatly for it.You see, packages online will tell you all about v-look up tables (I have never used one, but they are cool) and all about "well, this is a cell! have you heard of it?" but not once does a document stop and say "You there! Excel user-- did you know you can just put a "$" after the column or row name you want to reference and it will fix your reference to that column or row?"

So fast forward to R.  Only recently did I understand the part of the CRAN-R documentation that talked about what to do with the setwd() command. Working directory? To a former English major, that sounds like "oh, it's an address book for people I work with! Why the hell do I need that in R? Wait! I LOVE APPS! I LOVE APPLE! It must be an APP for R, how cool!" No, we don't think, "that's where it keeps all the files I would use"-- even if we did, I know I would have thought, who the hell needs "files" for R-- it's just a confusing sort of calculator that does statistics, too.

So right now I'm working on learning nested experimental design in R.  Could I do it in MatLab-- probably-- but the benefit of R is that our biometricians also use it, and if I screw something up on the ecological side, then I have some people to turn to. I'm documenting it both in R and in a "answering BRORBs questions" word document--- note to self, after I finish this one, I'm graduating the LaTeX, because geez, I am not satisfied with the MSWord equation thing-- and they don't open up in some older versions of Office.  I realize as I'm writing it that although to me something like

par(mfcol=c(2,2))
hist(median, col="blue")
hist(mean, col="red")
boxplot(median)
title("boxplot of median")
plot(avg, trend, xlab="mean index", ylab="mean index", main="scatter plot of indices")

to me now seems a fairly obvious way to put four graphs onto one graph plot in a form that can be exported as PDF or JPG, for anyone else, especially people who don't really stare at R for hours on end, that just looks like a boat of jargon. Not to mention someday when I am an ancient hoary old professor, I will say to my students, "back in the day if I wanted to plot four graphs I had to type all this crap" and they will say "geez! All I have to do is THINK of what I want and it magically appears on a three-D hologram in the middle of the room, along with Princess Leah" and then the Star Wars theme will start playing and my favorite physicist will come flying in on the millenium falcon along with a wookie named Chewie and.... wait... I'm getting carried away.  Maybe R documentation and MatLab documentation are not the Force holding the universe together...but last I heard Yoda was hanging out saying "Document the code you will."

No comments:

Post a Comment