I'm thinking of a scenario where students have a dataframe:
df <- data.frame(person=c('bob', 'bill', 'jane'), age=c(60, 65, 70))
and they need to determine the mean of the age column. Ideally we'd want students to do
my.mean <- mean(df$age)
And we would use testthat to check that mean(df$age) is the correct answer:
test_that("mean age is correct", {expect_equal(my.mean, 65)})
But if a student is not sure of how to answer the question, they could calculate the mean themselves (by eye or with a calculator, not using code) and submit
my.mean <- 65
Is there a way to check that students are using code or specific functions to determine their answers?
test_that("mean age is correct", { << something that checks if the function mean was used to generate the answer >> })