diff --git a/DESCRIPTION b/DESCRIPTION index f11a912..fba0b3a 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: + graphics, Rcpp 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/NEWS.md b/NEWS.md deleted file mode 100644 index 74d43c9..0000000 --- a/NEWS.md +++ /dev/null @@ -1,3 +0,0 @@ -# egpkg 1.0 - -* Initial CRAN submission. diff --git a/R/myplot.R b/R/myplot.R new file mode 100644 index 0000000..902367a --- /dev/null +++ b/R/myplot.R @@ -0,0 +1,31 @@ +#' Here is the function +#' @export +#' @param x A numeric vector +#' @param y A numeric vector +#' @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/man/myplot.Rd b/man/myplot.Rd new file mode 100644 index 0000000..c5dd853 --- /dev/null +++ b/man/myplot.Rd @@ -0,0 +1,24 @@ +% 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 +} +\examples{ + +#Here is an example +set.seed(312) +x <- rnorm(100) +y <- rnorm(100) +myplot(x, 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/test-myplot.R b/tests/testthat/test-myplot.R new file mode 100644 index 0000000..a6c49a9 --- /dev/null +++ b/tests/testthat/test-myplot.R @@ -0,0 +1,5 @@ +test_that("multiplication works", { + expect_error(myplot("a","b"),message = "x and y must be numeric") + expect_error(myplot(1,"b"),message = "x and y must be numeric") + expect_error(myplot("a",1),message = "x and y must be numeric") +})