diff --git a/R/myplot.R b/R/myplot.R new file mode 100644 index 0000000..1922336 --- /dev/null +++ b/R/myplot.R @@ -0,0 +1,29 @@ +#' Here is the function +#' @param x A numeric vector +#' @param y A numeric vector +#' @export +#' @import graphics +#' @examples +#' # Here is an example +#' set.seed(312) +#' x <- rnorm(100) +#' y <- rnorm(100) +#' myplot(x, y) +myplot <- function(x, y) { + + if (!is.numeric(x) | !is.numeric(y)) { + stop("x and y must be numeric") + } + + plot(x, y, col = "blue", pch = 19, cex = 2) + + invisible( + list( + x = x, + y = y + ) + ) + +} + + diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..76adaf1 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,12 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library(testthat) +library(egpkg) + +test_check("egpkg") diff --git a/tests/testthat/Rplots.pdf b/tests/testthat/Rplots.pdf new file mode 100644 index 0000000..be44aec Binary files /dev/null and b/tests/testthat/Rplots.pdf differ diff --git a/tests/testthat/test-myplot.R b/tests/testthat/test-myplot.R new file mode 100644 index 0000000..70d14a5 --- /dev/null +++ b/tests/testthat/test-myplot.R @@ -0,0 +1,5 @@ +test_that("multiplication works", { + expect_equal(2 * 2, 4) + expect_error(myplot(2 * "a")) + expect_silent(myplot(2, 2)) +})