Practice
R Coding Questions
Each question presents a biological scenario and R code. Identify any mistakes in the code or analysis — or write "No mistakes" if there are none.
Q1One-Way ANOVA
?One-Way ANOVA: maze-completion time across sound conditions
A biology student is studying whether different types of "productivity music" affect how quickly lab mice complete a simple maze. Mice are randomly assigned to one of three sound conditions: silence, classical, or lofi_beats. The response variable is maze completion time (seconds), stored in a CSV file.
The student imports and inspects the data:
# a.
mouseData <-
read.csv("DataForLabs/MouseMazeMusicData.csv",
stringsAsFactors = TRUE)
# b.
mouseDatamaze_time sound_condition 1 42 silence 2 45 silence 3 44 silence 4 47 silence 5 43 silence 6 39 classical 7 41 classical 8 38 classical 9 40 classical 10 42 classical 11 35 lofi_beats 12 37 lofi_beats 13 36 lofi_beats 14 34 lofi_beats 15 38 lofi_beats
The student wants to test H₀: μsilence = μclassical = μlofi_beats vs. HA: at least one group mean differs, with α = 0.05. They write:
# c. anova(maze_time ~ sound_condition, data = mouseData)
Task
Please identify and explain any mistakes in the analysis or conclusions. If there are none, write "No mistakes".