Learn R Programming

⚠️There's a newer version (0.3-6) of this package.Take me there.

assertive (version 0.3-0)

Readable Check Functions to Ensure Code Integrity

Description

Lots of is_* functions to check the state of your variables, and assert_* functions to throw errors if they aren't in the right form.

Copy Link

Version

Install

install.packages('assertive')

Monthly Downloads

299

Version

0.3-0

License

GPL (>= 3)

Maintainer

Richard Cotton

Last Published

July 15th, 2015

Functions in assertive (0.3-0)

as.character.file

Convert file connections to strings
assert_has_duplicates

Does the input have duplicates?
assert_is_all_of

Does x belong to these classes?
Truth

Is the input TRUE/FALSE/NA?
assert_all_are_date_strings

Does the character vector contain dates?
has_arg

Does the current call have an argument?
assert_is_atomic

Is the input atomic/recursive/vector?
assert_is_function

Is the input a function?
assert_is_array

Is the input an array or matrix?
DIM

Get the dimensions of an object
get_name_in_parent

Get the name of a variable in the parent frame
assert_has_colnames

Does the input have names?
is2

Alternative version of is
assert_all_are_honorifics

Is the string an honorific?
are_same_length

Are the inputs the same length
assert_is_loaded

Is the input DLL loaded?
assert_is_binding_locked

Is the binding of a variable locked?
assert_engine

Throws an error if a condition isn't met
assert_has_all_attributes

Does the input have the specified attributes?
assert_is_inherited_from

Does the object inherit from some class?
assert_has_cols

Does the input have rows/columns?
assert_is_batch_mode

How is R running?
assert_is_bzfile_connection

Is the input a connection?
not_this_build

Failure for bad build
has_any_attributes

Does the input have any attributes?
changes

Important changes to assertive
assert_is_list

Is the input a list?
assert_is_a_complex

Is the input complex?
cause

Get or set the "cause" attribute
assert_is_data.frame

Checks to see if the input is a data.frame.
assert_is_not_null

Is the input (not) null?
assertive

Readable check functions to ensure code integrity.
are_identical

Are the inputs identical
assert_has_elements

Is the input empty/scalar?
assert_is_a_number

Is the input numeric?
assert_is_leaf

Is the input a (dendrogram) leaf?
call_and_name

Call a function, and give the result names.
is_relistable

Is the input relistable?
assert_has_terms

Does the input have terms?
bapply

Wrapper to vapply that returns booleans.
d

Create regex for repeated digits
assert_all_are_divisible_by

Is the input divisible by a number?
assert_all_are_libraries

Is the directory a known R library?
assert_all_are_uk_car_licences

Is the string a valid UK car licence plate number?
n_elements

Get the number of elements
strip_invalid_chars

Removes invalid characters from a string.
assert_is_current_r

Is this version of R up to date?
false

FALSE, with a cause of failure.
assert_is_64_bit_os

What OS is running?
locale_categories

Allowed locale categories.
assert_is_a_bool

Is the input logical?
assert_all_are_finite

Are the inputs (in)finite?
assert_all_are_cas_numbers

Does the character vector contain CAS registry numbers?
assert_has_dims

Does the input have dimensions?
create_regex

Create a regex from components.
assert_is_if_condition

Is suitable to be used as an if condition
assert_are_set_equal

Set comparisons
dont_stop

Run code without stopping
assert_is_factor

Is the input an factor?
assert_all_are_executable_files

Is the file accessible?
assert_is_raster

Is the input a raster?
character_to_list_of_integer_vectors

Convert a character vector to a list of integer vectors.
recycle

Recycle arguments
assert_all_are_hex_colors

Does the character vector contain hex colors?
assert_all_are_dirs

Is the path a directory? Checks to see if the input path is a directory.
assert_all_are_email_addresses

Does the character vector contain email addresses?
assert_all_are_isbn_codes

Does the character vector contain ISBN book codes?
coerce_to

Coerce variable to a different class
assert_all_are_credit_card_numbers

Does the character vector contain credit card numbers?
assert_is_empty_model

Is the input the empty model?
assert_all_numbers_are_whole_numbers

Is the input a whole number?
assert_all_are_existing

Does the variable exist?
assert_all_are_existing_files

Does the file exist?
assert_is_a_raw

Is the input raw?
is_error_free

Does the code run without throwing an error?
assert_all_are_valid_variable_names

Is the string a valid variable name?
assert_all_are_imaginary

Is the input real/imaginary?
assert_all_are_us_telephone_numbers

Is the string a valid US telephone number?
matches_regex

Does the input match the regular expression?
set_cause

Set a cause and return the input
assert_all_are_us_zip_codes

Is the string a valid US zip code?
assert_is_comma_for_decimal_point

What does the current locale specify for the decimal point?
assert_is_environment

Is the input an environment?
assert_is_unsorted

Is the input unsorted?
use_first

Only use the first element of a vector
assert_is_call

Is the input a language object?
make_range_string

Make a range string
is_rstudio_current

Is RStudio the current version?
merge_dots_with_list

Merge ellipsis args with a list.
assert_all_are_in_future

Is the input in the past/future?
is_rstudio_desktop

Is RStudio running in desktop or server mode?
assert_is_S4

Is the input an S4 object?
na

NA, with a cause of failure.
assert_is_table

Is the input a table?
assert_all_are_uk_postcodes

Is the string a valid UK postcode?
assert_is_valid_r_code

Is the input valid R code?
assert_all_are_uk_national_insurance_numbers

Is the string a valid UK national insurance number?
assert_all_are_ip_addresses

Does the character vector contain IP addresses?
assert_all_are_single_characters

Is the input a single character?
is_package_current

Is the installed version of a package current?
assert_is_mts

Is the input a time series?
assert_all_are_classes

Is the input the name of a (formally defined) class?
assert_is_an_integer

Is the input an integer?
sys_get_locale

Get or set the system locale
not_this_os

Failure for bad OS
assert_all_are_uk_telephone_numbers

Is the string a valid UK telephone number?
assert_is_symmetric_matrix

Is the input a symmetric matrix?
assert_all_are_nan

Is the input (not) NaN?
assert_is_qr

Is the input a QR decomposition of a matrix?
parenthesize

Wrap a string in brackets
assert_all_are_on_os_path

Is the path on the OS path?
assert_r_can_find_tools

Can R find tools?
assert_is_architect

Are you running R?
assert_is_a_non_empty_string

Is the input of type character?
assert_is_debugged

Is the input function being debugged?
assert_all_are_empty_files

Is a file empty?
assert_r_has_jpeg_capability

Does R have a capability?
rstudio_version_info

Get RStudio's version information
assert_all_are_in_closed_range

Is the input in range?
strip_attributes

Strip all attributes from a variable
warn_about_file.access_under_windows

Warn about file.access under Windows