diff --git a/DESCRIPTION b/DESCRIPTION index f11a912..fd7d9a5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,8 +9,12 @@ Description: One paragraph description of what the package does as one or more full sentences. License: GPL (>= 2) Imports: - Rcpp + Rcpp, + graphics LinkingTo: Rcpp Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Encoding: UTF-8 +Suggests: + testthat (>= 3.0.0) +Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index 8f279de..3c2b4d5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,7 @@ # Generated by roxygen2: do not edit by hand +export(myplot) export(rcpp_hello_world) +import(graphics) importFrom(Rcpp,evalCpp) useDynLib(egpkg, .registration = TRUE) diff --git a/R/myplot.R b/R/myplot.R new file mode 100644 index 0000000..e2a167c --- /dev/null +++ b/R/myplot.R @@ -0,0 +1,24 @@ + +#' Here is the function +#' @param x A Numeric Vector. +#' @param y A Numeric Vector. +#' @export +#' @import graphics + + +myplot <- function(x, y) { + + if (!is.numeric(x) | !is.numeric(y)) { + stop("x and y must be numeric") + } + + graphics::plot(x, y, col = "blue", pch = 19, cex = 2) + + invisible( + list( + x = x, + y = y + ) + ) + +} diff --git a/man/myplot.Rd b/man/myplot.Rd new file mode 100644 index 0000000..9645d82 --- /dev/null +++ b/man/myplot.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/myplot.R +\name{myplot} +\alias{myplot} +\title{Here is the function} +\usage{ +myplot(x, y) +} +\arguments{ +\item{x}{A Numeric Vector.} + +\item{y}{A Numeric Vector.} +} +\description{ +Here is the function +} 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..65cc8d3 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..a1206ba --- /dev/null +++ b/tests/testthat/test-myplot.R @@ -0,0 +1,6 @@ +test_that("multiplication works", { + expect_error(myplot(1, 'o')) + expect_error(myplot('a', 1)) + expect_s3_class(myplot(1,1), 'list') + +})