Thursday, June 9, 2016

R the 2nd

My previous R post was a month ago.

The dogs wanted to go chase deer at 3:30 this morning. I always get up when they wake me up because I don't know if it is wildlife or some bodily function that is the source of their urgency. Now it's four o'clock -- in the morning -- and I have no urgent needs of my own. Nothing greater than a second cup of coffee.

I avoid Reddit, leaving my mind clear while my own thoughts float to the surface: "Let's look for Getting started with R." Okay.

Ooh, RStudio, an integrated development environment. I have luck with IDEs. But, later.

Ooh, a wiki. Yeah. From York University in Toronto. Lots of links. "Print a copy of Tom Short's R reference card" catches my eye, but isn't working.

Then "if you're an experienced programmer just getting starting with R you might really enjoy The R Inferno by Patrick Burns". The word "enjoy" causes hesitation, but I consider myself an experienced programmer, so I click.

126 pages. Oh, well.

Some one-line examples on page 11 (the text starts on page 9 so that's not bad). I start R and try the examples. Same results as shown in the PDF. Good start.

Short chapter. That's good.

Next chapter opens showing three ways to do one task. Interesting -- interesting to me, anyway -- but I don't want to get into this now. I want to get started before I start picking the best way to do something. I want to find Tom Short's R reference card.

Got it.

PDF, four pages, dense. Perfect.

Notice that most of these commands (like help and apropos and str) are followed by parentheses and
that there is often something inside the parentheses That tells me these commands are functions,
like in C. You give the function information. The function uses that information to figure something,
and when done it returns a value to you. The info you provide goes inside the parentheses.

When you are learning a language, the main thing you need is the words and their meanings. That's what reference cards are for. Read the whole reference card a couple times, then put it aside and think about other things. Eventually there is some calculation you need to work out, a simple one, and you say: Maybe I can do this in R. Two or three words from the card pop into your head and you arrange them in order like a sentence and you say Yeah this'll work. You're on your way.

Might not be the best way if this is the first time you're learning a language. But I always needed simple tasks to start with. My first project in Assembler was to clear the screen on my Commodore-64. In VBA, to open a file.

I print the card. Print first to doPDFv7 (which creates a PDF, not a paper printout) to see if it is landscape and to make sure nothing is cut off. All good, so I send it to my printer.


I keep the first two pages and print the last two from the doPDF output PDF. That works.

It's always somethin.

Could be the most useful thing I've printed in years.


The dogs lie patiently while I prepare their breakfast, waiting to lick my finger while waiting for me to finish. When I put the spoon in the can and set the can down they get up, knowing that breakfast is ready. How do they know?