[R] Learning the R way – A Wish
andrewH
ahoerner at rprogress.org
Tue Mar 5 00:42:28 CET 2013
There is something that I wish I had that I think would help me a lot to be a
better R programmer, that I think would probably help many others as well.
I put the wish out there in the hopes that someone might think it was worth
doing at some point.
I wish I had the code of some substantial, widely used package – lm, say –
heavily annotated and explained at roughly the level of R knowledge of
someone who has completed an intro statistics course using R and picked up
some R along the way. The idea is that you would say what the various
blocks of code are doing, why the authors chose to do it this way rather
than some other way, point out coding techniques that save time or memory or
prevent errors relative to alternatives, and generally, to explain what it
does and point out and explain as many of the smarter features as possible.
Ideally, this would include a description at least at the conceptual level
if not at the code level of the major C functions that the package calls, so
that you understand at least what is happening at that level, if not the
nitty-gritty details of coding.
I imagine this as a piece of annotated code, but maybe it could be a video
of someone, or some couple of people, scrolling through the code and talking
about it. Or maybe something more like a wiki page, with various people
contributing explanations for different lines, sections, and practices.
I am learning R on my own from books and the internet, and I think I would
learn a lot from a chatty line-by-line description of some substantial block
of code by someone who really knows what he or she is doing – perhaps with a
little feedback from some people who are new about where they get lost in
the description.
There are a couple of particular things that I personally would hope to get
out of this. First, there are lots of instances of good coding practice
that I think most people pick up from other programmers or by having
individual bits of code explained to them that are pretty hard to get from
books and help files. I think this might be a good way to get at them.
Second, there are a whole bunch of functions in R that I call
meta-programming functions – don’t know if they have a more proper name.
These are things that are intended primarily to act on R language objects or
to control how R objects are evaluated. They include functions like call,
match.call, parse and deparse, deparen, get, envir, substitute, eval, etc.
Although I have read the individual documentation for many of these command,
and even used most of them, I don’t think I have any fluency with them, or
understand well how and when to code with them. I think reading a
good-sized hunk of code that uses these functions to do a lot of things that
packages often need to do in the best-practice or standard R way, together
with comments that describe and explain them would help a lot with that.
(There is a good smaller-scale example of this in Friedrich Leisch’s
tutorial on creating R packages).
These are things I think I probably share with many others. I actually have
an ulterior motive for suggesting lm in particular that is more peculiar to
me, though not unique I am sure. I would like to understand how formulas
work well enough to use them in my own functions. I do not think there is
any way to get that from the help documentation. I have been working on a
piece of code that I suspect is reinventing, but in an awkward and kludgey
way, a piece of the functionality of formulas. So far as I have been able to
gather, the only place they are really explained in detail is in chapters 2
& 3 of the White Book, “Statistical Models in S”. Unfortunately, I do not
have ready access to a major research library and I have way, way outspent
my book budget. Someday I’ll probably buy a copy, but for the time being, I
am stuck without it. So it would be great to have a piece of code that uses
them explained in detail.
Warmest regards to all, andrewH
--
View this message in context: http://r.789695.n4.nabble.com/Learning-the-R-way-A-Wish-tp4660287.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list