hello_world()function that returns the string "Hello World". For the sake of simplicity, it doesn't print anything.
setwdspecifies a working directory. This allows us to
sourcethe files without specifying the path.
source("exercise.R", chdir = TRUE)
Rto accept the input from the named file, so the tests know what function to run.
testthatpackage, that we use to run the tests.
"returns hellow world string"that asserts equality of "Hello world" string and the students' function output.
print()function to print the argument. We are using
quote=FALSEargument to remove the quote from printting, print prints quotes the output by default.
capture_outputfunction that is provided by
testthatpackage. This function captures the output and returns a single string.
capture_output_linesfunction that returns a character vector with one entry for each line like this.
c()function to form a vector.
read.csvto read the data from csv-file. It returns a data frame.
data.frame("Name" = "Test Student", "Test1" = 60, "Test2" = 73, "Test3" = 79)
expect_equal(dim(merge(actual, expected)), dim(actual))
expect_equal(actual, expected)for small dataframes instead, but for the large ones we'll have to merge the expected data frame with the result data frame and check that the dimensions of result is the same.