THE BOOK cover
The Unwritten Book is Finally Written!
An in-depth analysis of: The sacrifice bunt, batter/pitcher matchups, the intentional base on balls, optimizing a batting lineup, hot and cold streaks, clutch performance, platooning strategies, and much more.
Read Excerpts & Customer Reviews

Buy The Book from Amazon


SABR101 required reading if you enter this site. Check out the Sabermetric Wiki. And interesting baseball books.
MOST RECENT ARTICLES
MAIL : You ask | We say

Advanced


THE BOOK--Playing The Percentages In Baseball

Filter posts by...

 

Wednesday, January 05, 2011

Another R primer

By Tangotiger, 12:16 PM

This time, Millsy is giving us the walk-through.

***

As an aside, for variable names, perhaps periods (.) is the standard for R and other languages, and I’ve seen hyphens used as well in other languages.  But, those characters are sometimes considered invalid in a field name (because after all they mean something specific, like a period in a decimal, or a hyphen would be a minus sign).  You can save yourself the trouble and use an underscore (_).  I’ve never come across any language that doesn’t like the underscore.  If I’m wrong, then let me know.

He’s right about never starting a field name with a numeric.  Some languages are ok with it, but most are not.  For something like double, I simply do B2, and triples is B3, simply inverting 2B and 3B.  Then, to complete it, you can do B1 for singles, and either stick with HR or go to B4 for consistency sake.  Then you can expand that for other things like BE for reaching on error, and so on.  BB is walks obviously.  They all follow the form “base on”.

Anyway, what I’ve said here is a footnote of a footnote compared to what Millsy is telling you, so, spend your time following his tutorial instead.

(12) Comments • 2011/01/08 • SabermetricsTechnology
Page 1 of 1 pages

Latest...

COMMENTS

May 21 07:42
Cory speaks!

May 21 07:40
Lincecum the catcher

May 21 07:35
Is the Shift actually working?

May 21 04:48
Extra, extra, read all about it: MLB has inter-conference play this weekend!

May 21 02:57
Are bullpen sessions predictive?

May 20 21:02
Poll: I would have suspended Lawrie/Alomar for ___ part of the season

May 20 20:59
How do you incentivize a power hitter to bunt?

May 20 14:22
Combining Rock-Paper-Scissors (RPS) with “What Number Am I Thinking Of”

May 20 11:51
When to buy Facebook?

May 19 23:47
Sponsoring MLB jerseys

THREADS

January 05, 2011
Another R primer