stat405

Homework 4

Due in class, 30 Sep.

Reading

Read coping with hitchhikers and couch potatoes on teams, and write a half-page essay on how you feel the paper relates to your past or present experiences.

Programming

As well as handling in a printed copy of your code (so I can write comments on it), you will also need to email me an electronic version. Your electronic submission should be named lastname-firstname.r (so mine would be wickham-hadley.r), it should run without errors if you run source("lastname-firstname.r"), and it should contain a single function called calculate_prize. Do not load the data or change the working directory (I'll be grading this code automatically).

Use the following code to check that your function works correctly (we'll be learning about this in a couple of weeks).

slots <- read.csv("slots.csv", stringsAsFactors = FALSE)

# A simple approximate to the prize function
calculate_prize <- function(windows) 0
# or alternatively: source("wickham-hadley.r")

library(plyr)
slots$check <- unlist(alply(as.matrix(slots[c("w1", "w2", "w3")]), 1, calculate_prize))
subset(slots, check != prize)

Drills

Do 10 function drills.

Grading scheme

Ten points according to the code rubric (rubric score divided by three).

Five points for correctness: 5 if all prizes correct, 4 if single mistake, 3 if two or more mistakes, 2 if multiple mistakes, 1 if mostly mistakes. Additionally, you'll lose points if I need to modify your code to get it run (if you code works with the sample above, you'll be fine).

Five points for your comments on the reading: 5 points for a reflective and thoughtful response, 4 for good, 3 for ok.

One point each for each function drill.