R and RStudio: difficulty 4

Mark Yourself Question

  1. Grab a piece of paper and try this problem yourself.
  2. When you're done, check the "I have answered this question" box below.
  3. View the solution and report whether you got it right or wrong.

A colleague sends you the following script, which runs correctly on their laptop.

1  setwd("/Users/jdavies/Desktop/final analysis 2")
2  plots <- read.csv("plots.csv")
3  plots$height <- as.numeric(gsub(" cm", "", plots$height_cm))
4  fit <- lmer(height ~ treatment + (1 | block), data = plots)
5  subset_rows <- plots[sample(nrow(plots), 20), ]
6  boxplot(height ~ treatment, data = subset_rows)

Answer all three parts.

  1. Identify the three statements that prevent this script from being reproducible on another machine, and explain in each case what specifically fails and for whom.
  2. Rewrite those three statements, stating where each rewritten line belongs in the script.
  3. Describe the concrete test that demonstrates the repaired script is reproducible, and explain why running it again on the original laptop would not be a valid test.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More R and RStudio Questions: