test and everything
This commit is contained in:
parent
c45fd3370c
commit
f2417bd16b
@ -9,3 +9,6 @@ License: GPL-3
|
|||||||
Encoding: UTF-8
|
Encoding: UTF-8
|
||||||
Roxygen: list(markdown = TRUE)
|
Roxygen: list(markdown = TRUE)
|
||||||
RoxygenNote: 7.2.1
|
RoxygenNote: 7.2.1
|
||||||
|
Suggests:
|
||||||
|
testthat (>= 3.0.0)
|
||||||
|
Config/testthat/edition: 3
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
# Generated by roxygen2: do not edit by hand
|
# Generated by roxygen2: do not edit by hand
|
||||||
|
|
||||||
|
export(filter2)
|
||||||
export(select2)
|
export(select2)
|
||||||
|
18
R/filter2.R
Normal file
18
R/filter2.R
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#' Filter function
|
||||||
|
#'
|
||||||
|
#' Alternative filtering function
|
||||||
|
#'
|
||||||
|
#' @param ds data frame
|
||||||
|
#' @param test logical vector , indices or row names
|
||||||
|
#'
|
||||||
|
#' @return Data frame filtered by test
|
||||||
|
#' @export
|
||||||
|
#'
|
||||||
|
#' @examples
|
||||||
|
#' filter2(iris,iris$Species=="virginica")
|
||||||
|
#' filter2(iris,2:10)
|
||||||
|
filter2 <- function(ds,test) {
|
||||||
|
ds[test,]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
23
man/filter2.Rd
Normal file
23
man/filter2.Rd
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/filter2.R
|
||||||
|
\name{filter2}
|
||||||
|
\alias{filter2}
|
||||||
|
\title{Filter function}
|
||||||
|
\usage{
|
||||||
|
filter2(ds, test)
|
||||||
|
}
|
||||||
|
\arguments{
|
||||||
|
\item{ds}{data frame}
|
||||||
|
|
||||||
|
\item{test}{logical vector , indices or row names}
|
||||||
|
}
|
||||||
|
\value{
|
||||||
|
Data frame filtered by test
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
Alternative filtering function
|
||||||
|
}
|
||||||
|
\examples{
|
||||||
|
filter2(iris,iris$Species=="virginica")
|
||||||
|
filter2(iris,2:10)
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
% Generated by roxygen2: do not edit by hand
|
% Generated by roxygen2: do not edit by hand
|
||||||
% Please edit documentation in R/slctr.R
|
% Please edit documentation in R/select2.R
|
||||||
\name{select2}
|
\name{select2}
|
||||||
\alias{select2}
|
\alias{select2}
|
||||||
\title{Simple select function using subset()}
|
\title{Simple select function using subset()}
|
||||||
|
1
setup.R
1
setup.R
@ -4,3 +4,4 @@ dir.create("R")
|
|||||||
usethis::use_package_doc()
|
usethis::use_package_doc()
|
||||||
usethis::use_roxygen_md()
|
usethis::use_roxygen_md()
|
||||||
|
|
||||||
|
usethis::use_package()
|
12
tests/testthat.R
Normal file
12
tests/testthat.R
Normal file
@ -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/tests.html
|
||||||
|
# * https://testthat.r-lib.org/reference/test_package.html#special-files
|
||||||
|
|
||||||
|
library(testthat)
|
||||||
|
library(minidplyr)
|
||||||
|
|
||||||
|
test_check("minidplyr")
|
5
tests/testthat/test-filter2.R
Normal file
5
tests/testthat/test-filter2.R
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
test_that("filter2() works with logicla vectors", {
|
||||||
|
df <- filter2(iris,c(T,F))
|
||||||
|
expect_s3_class(df, "data.frame")
|
||||||
|
expect_equal(dim(df), dim(iris)/2:1)
|
||||||
|
})
|
3
tests/testthat/test-slctr.R
Normal file
3
tests/testthat/test-slctr.R
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
test_that("multiplication works", {
|
||||||
|
expect_equal(2 * 2, 4)
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user