assertive.base v0.0-7

0

Monthly downloads

0th

Percentile

A Lightweight Core of the 'assertive' Package

A minimal set of predicates and assertions used by the assertive package. This is mainly for use by other package developers who want to include run-time testing features in their own packages. End-users will usually want to use assertive directly.

Readme

Project Status: Active - The project has reached a stable, usable state and is being actively developed. Is the package on CRAN? SemaphoreCI Build Status AppVeyor Build Status Codecov Test Coverage Status Coveralls Test Coverage Status

assertive.base

A minimal set of predicates and assertions used by assertive, for package developers who want to include run-time testing features in their own packages. Most of the documentation is on the assertive page. End-users will usually want to use assertive directly.

Installation

To install the stable version, type:

install.packages("assertive.base")

To install the development version, you first need the devtools package.

install.packages("devtools")

Then you can install the assertive.base package using

library(devtools)
install_bitbucket("richierocks/assertive.base")

Predicates

There are six functions that accept (expressions resolving to) logical vectors, and return logical vectors:

is_true returns a logical vector that is TRUE when the input is TRUE (x & !is.na(x)).

is_false returns a logical vector that is TRUE when the input is FALSE (!x & !is.na(x)).

is_na returns a logical vector that is TRUE when the input is NA (a wrapper to is.na(x)).

...and their negations:

is_not_true returns a logical vector that is TRUE when the input is FALSE or NA (x | is.na(x)).

is_not_false returns a logical vector that is TRUE when the input is TRUE or NA (!x | is.na(x)).

is_not_na returns a logical vector that is TRUE when the input is TRUE or FALSE (!is.na(x)).

There are four functions that return single logical values:

is_identical_to_true returns TRUE is effectively identical(x, TRUE) (like isTRUE), but it lets you choose whether or not attributes are allowed on x.

is_identical_to_false and is_identical_to_na works similarly with FALSE and NA.

are_identical wraps base::identical, checking if two expressions return the same thing.

Assertions

Predicates that return a vector have two corresponding assertions. For example, is_true has assert_all_are_true and assert_any_are_true.

Predicates returning a single logical value have one corresponding assertion. For example, is_identical_to_true has assert_is_identical_to_true.

Utilities

use_first takes the first value of a vector, warning you if it one longer than length one.

coerce_to is a wrapper to as, changing an object's type with a warning.

get_name_in_parent gets the name of a variable in the parent environment (stopping you have to remember deparse(substitute()) arcana).

strip_attributes strips the attributes from an object.

merge_dots_with_list merges the contents of ... with a list argument, to allow users to pass arguments to your function in either form.

dont_stop runs code without stopping at errors, which is useful for demonstrating errors in examples.

parenthesise wraps a string in parentheses.

bapply is a wraps vapply, always returning a logical vector.

Functions in assertive.base

Name Description
assertionError Condition classes
coerce_to Coerce variable to a different class
bapply Wrapper to vapply that returns booleans
set_cause Set a cause and return the input
print.scalar_with_cause Print methods for objects with a cause attribute
merge.list Merge two lists
is2 Alternative version of is
strip_attributes Strip all attributes from a variable
na NA, with a cause of failure.
merge_dots_with_list Merge ellipsis args with a list.
parenthesize Wrap a string in brackets
print_and_capture Print a variable and capture the output
safe_deparse Safe version of deparse
Truth Is the input TRUE/FALSE/NA?
use_first Only use the first element of a vector
assert_engine Throws an error if a condition isn't met
get_name_in_parent Get the name of a variable in the parent frame
false FALSE, with a cause of failure.
are_identical Are the inputs identical?
dont_stop Run code without stopping
call_and_name Call a function, and give the result names.
cause Get or set the "cause" attribute
No Results!

Last month downloads

Details

Type Package
Date 2016-12-22
URL https://bitbucket.org/richierocks/assertive.base
BugReports https://bitbucket.org/richierocks/assertive.base/issues
License GPL (>= 3)
LazyLoad yes
LazyData yes
Acknowledgments Development of this package was partially funded by the Proteomics Core at Weill Cornell Medical College in Qatar . The Core is supported by 'Biomedical Research Program' funds, a program funded by Qatar Foundation. Ukranian translations were supported by www.coupofy.com.
RoxygenNote 5.0.1
ByteCompile true
NeedsCompilation no
Packaged 2016-12-29 18:59:25 UTC; richierocks
Repository CRAN
Date/Publication 2016-12-30 00:22:35

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/assertive.base)](http://www.rdocumentation.org/packages/assertive.base)