#context("bonuslab")
data("iris")
Polygon <- setRefClass("Polygon", fields = c("sides"))
square <- Polygon$new(sides = 4)
test_that("lenreg rejects errounous input", {
expect_error(linreg_mod <- ridgereg$new(formula = Petal.Length~Sepdsal.Width+Sepal.Length, data=iris,1))
expect_error(linreg_mod <- ridgereg$new(Petal.Length~Sepdsal.Width+Sepal.Length, data=iris,c(1,2)))
expect_error(linreg_mod <- ridgereg$new(formula = Petal.Length~Sepdsal.Width+Sepal.Length, data=irfsfdis,1))
})
test_that("class is correct", {
linreg_mod <- ridgereg$new(Petal.Length~Sepal.Width+Sepal.Length, data=iris,1)
expect_true(class(linreg_mod)[1] == "ridgereg")
})
test_that("print() method works", {
ridgereg_mod <- ridgereg$new(Petal.Length~Sepal.Width+Sepal.Length, data=iris,1)
expect_output(ridgereg_mod$print(),"ridgereg\\(formula = Petal\\.Length ~ Sepal\\.Width \\+ Sepal\\.Length, data = iris\\)")
expect_output(ridgereg_mod$print(),"( )*\\(Intercept\\)( )*Sepal\\.Width( )*Sepal\\.Length")
})
test_that("pred() method works", {
linreg_mod <- ridgereg$new(Petal.Length~Sepal.Width+Sepal.Length, data=iris,1)
linreg_mod$QR()
expect_equal(round(unname(linreg_mod$pred()[c(1,5,7)]),2), c(1.88, 1.56, 1.19))
})
test_that("coef() method works", {
linreg_mod <- ridgereg$new(Petal.Length~Sepal.Width+Sepal.Length, data=iris,1)
linreg_mod$QR()
expect_true(all(round(unname(linreg_mod$coef()),2) %in% c(-2.52, -1.34, 1.78)))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.