Learn R Programming

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

assertive (version 0.2-1)

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.2-1

License

Unlimited

Maintainer

Richard Cotton

Last Published

February 4th, 2015

Functions in assertive (0.2-1)

assert_all_are_email_addresses

Does the character vector contain email addresses?
assert_all_are_cas_numbers

Does the character vector contain CAS registry numbers?
assert_is_architect

Are you running R?
are_same_length

Are the inputs the same length
assert_all_are_date_strings

Does the character vector contain dates?
locale_categories

Allowed locale categories.
cause

Get or set the "cause" attribute.
has_arg

Does the current call have an argument?
assert_is_raster

Is the input a raster?
character_to_list_of_integer_vectors

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

Only use the first element of a vector.
is_error_free

Does the code run without throwing an error?
coerce_to

Coerce variable to a different class.
assert_is_a_bool

Is the input logical?
assert_all_are_credit_card_numbers

Does the character vector contain credit card numbers?
assert_all_are_libraries

Is the directory a known R library?
assert_is_qr

Is the input a QR decomposition of a matrix?
assert_is_batch_mode

How is R running?
modal_value

The most common value in a vector.
create_regex

Create a regex from components.
n_elements

Get the number of elements
assert_all_are_uk_car_licences

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

Is the input a table?
assertive

Readable check functions to ensure code integrity.
d

Create regex for repeated digits
set_cause

Set a cause and return the input
assert_is_array

Is the input an array or matrix?
assert_all_are_us_telephone_numbers

Is the string a valid US telephone number?
assert_r_can_compile_code

Can R find tools for compiling code?
assert_all_are_us_zip_codes

Is the string a valid US zip code?
assert_is_factor

Is the input an factor?
assert_all_are_valid_variable_names

Is the string a valid variable name?
false

FALSE, with a cause of failure.
DIM

Get the dimensions of an object
assert_is_unsorted

Is the input unsorted?
assert_is_a_number

Is the input numeric?
assert_is_data.frame

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

Does the variable exist?
dont_stop

Run code without stopping
has_any_attributes

Does the input have any attributes?
assert_is_empty_model

Is the input the empty model?
assert_has_elements

Is the input empty/scalar?
assert_is_call

Is the input a language object?
assert_all_are_isbn_codes

Does the character vector contain ISBN book codes?
assert_has_terms

Does the input have terms?
assert_all_are_uk_telephone_numbers

Is the string a valid UK telephone number?
as.character.file

Convert file connections to strings
assert_all_are_uk_postcodes

Is the string a valid UK postcode?
assert_all_are_in_closed_range

Is the input in range?
assert_is_atomic

Is the input atomic/recursive/vector?
assert_all_are_existing_files

Does the file exist?
assert_is_environment

Is the input an environment?
assert_all_are_empty_files

Is a file empty?
assert_is_64_bit_os

What OS is running?
assert_has_cols

Does the input have rows/columns?
assert_is_debugged

Is the input function being debugged?
assert_is_a_complex

Is the input complex?
get_name_in_parent

Get the name of a variable in the parent frame.
assert_all_are_classes

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

Is the input a connection?
is_valid_r_code

Is the input valid R code?
strip_invalid_chars

Removes invalid characters from a string.
assert_is_an_integer

Is the input an integer?
bapply

Wrapper to vapply that returns booleans.
assert_all_are_divisible_by

Is the input divisible by a number?
assert_all_are_in_future

Is the input in the past/future?
assert_is_function

Is the input a function?
merge.list

Merge two lists
assert_all_are_executable_files

Is the file accessible?
are_identical

Are the inputs identical
strip_attributes

Strip all attributes from a variable.
call_and_name

Call a function, and give the result names.
assert_engine

Throws an error if a condition isn't met.
assert_is_a_non_empty_string

Is the input of type character?
matches_regex

Does the input match the regular expression?
assert_all_are_dirs

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

Is the input real/imaginary?
assert_all_are_hex_colors

Does the character vector contain hex colours?
assert_is_S4

Is the input an S4 object?
assert_has_dims

Does the input have dimensions?
assert_r_has_jpeg_capability

Does R have a capability?
assert_all_are_ip_addresses

Does the character vector contain IP addresses?
truncate

Truncate a string
assert_all_are_uk_national_insurance_numbers

Is the string a valid UK national insurance number?
assert_is_loaded

Is the input DLL loaded?
assert_all_are_not_na

Is the input present/missing?
assert_all_are_on_os_path

Is the path on the OS path?
assert_all_are_single_characters

Is the input a single character?
assert_has_all_attributes

Does the input have the specified attributes?
is_relistable

Is the input relistable?
recycle

Recycle arguments
assert_is_a_raw

Is the input raw?
assert_all_numbers_are_whole_numbers

Is the input a whole number?
assert_is_symmetric_matrix

Is the input a symmetric matrix?
assert_has_colnames

Does the input have names?
print_and_capture

Print a variable and capture the output
assert_all_are_nan

Is the input (not) NaN?
na

NA, with a cause of failure.
assert_is_inherited_from

Does the object inherit from some class?
merge_dots_with_list

Merge ellipsis args with a list.
parenthesise

Wrap a string in brackets
warn_about_file.access_under_windows

Warn about file.access under Windows
assert_is_mts

Is the input a time series?
assert_is_comma_for_decimal_point

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

Is the input TRUE?
assert_has_duplicates

Does the input have duplicates?
assert_is_not_null

Is the input (not) null?
assert_is_all_of

Alternative version of is.
assert_is_list

Is the input a list?
assert_all_are_finite

Are the inputs (in)finite?
is_honorific

Is the string an honorific?
assert_is_leaf

Is the input a (dendrogram) leaf?
sys_get_locale

Get or set the system locale