Part I. Project 1: Weighted Dice

Computers let you assemble, manipulate, and visualize data sets, all at speeds that would have wowed yesterday’s scientists. In short, computers give you scientific superpowers! But you’ll need to pick up some programming skills if you wish to fully utilize them.

As a data scientist who knows how to program, you will improve your ability to:

  • Memorize (store) entire data sets
  • Recall data values on demand
  • Perform complex calculations with large amounts of data
  • Do repetitive tasks without becoming careless or bored

Computers can do all of these things quickly and error free, which lets your mind do the things it excels at: making decisions and assigning meaning.

Sound exciting? Great! Let’s begin.

When I was a college student, I sometimes daydreamed of going to Las Vegas. I thought that knowing statistics might help me win big. If that’s what led you to data science, you better sit down; I have some bad news. Even a statistician will lose money in a casino over the long run. This is because the odds for each game are always stacked in the casino’s favor. However, there is a loophole to this rule. You can make money—and reliably too. All you have to do is be the casino.

Believe it or not, R can help you do that. Over the course of the book, you will use R to build three virtual objects: a pair of dice that you can roll to generate random numbers, a deck of cards that you can shuffle and deal from, and a slot machine modeled after some real-life ...

Get Hands-On Programming with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.