setwd("/home/guerzhoy/Desktop/sml201/precepts/P3") #CHANGE THIS source("p3.R") # DO NOT CHANGE THIS library(dplyr) library(gapminder) if(assignment != "precept3"){ stop("This is a checker for Precept 3, but assignment is not set to 'precept3'") } cat("Checking Precept 3 submission for", student.netid.1, "and", student.netid.2, "\n") cat("Checking MostAccuratePred\n") stopifnot(exists("MostAccuratePred")) gap.small <- (gapminder %>% filter(year==1982))[1:11,] stopifnot(all(sort(MostAccuratePred(gap.small)) == sort(c( "Belgium", "Austria", "Algeria","Australia","Benin", "Bahrain", "Argentina", "Bangladesh", "Afghanistan", "Albania" )))) cat("Checking my.lm\n") stopifnot(exists("my.lm")) my.data <- data.frame(X = c(1, 2, 3), Y = c(3.1, 4.9, 7.05)) stopifnot(my.lm(my.data, 1)==2) cat("Checking predictGdpCont") stopifnot(exists("predictGdpCont")) vec <- c(0, 1, 2, 3, 4) names(vec) <- c("(Intercept)", "continentAmericas", "continentAsia", "continentEurope", "continentOceania") stopifnot(predictGdpCont(vec, "Asia") == 2) cat("Done. If there are errors, you *must* fix them. Passing the tests above does not guarantee your program works in all situations.")