Learn R Programming

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

assertive (version 0.3-2)

Readable Check Functions to Ensure Code Integrity

Description

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

Copy Link

Version

Install

install.packages('assertive')

Monthly Downloads

166

Version

0.3-2

License

GPL (>= 3)

Maintainer

Richard Cotton

Last Published

March 8th, 2016

Functions in assertive (0.3-2)

is_divisible_by

Is the input divisible by a number?
is_xxx_for_decimal_point

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

Does the character vector contain hex colors?
is_r_current

Is this version of R up to date?
is_real

Is the input real/imaginary?
is_finite

Are the inputs (in)finite?
are_same_length

Are the inputs the same length/dimension?
has_attributes

Does the input have the specified attributes?
is_character

Is the input of type character?
is_empty_character

Does the input contain empty or missing strings?
is_language

Is the input a language object?
is_class

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

Is the input atomic/recursive/vector?
call_and_name

Call a function, and give the result names.
are_identical

Are the inputs identical?
has_cols

Does the input have rows/columns?
is_date_string

Does the character vector contain dates?
is_leaf

Is the input a (dendrogram) leaf?
is_debugged

is_dir

Is the path a directory?
has_arg

has_terms

Does the input have terms?
is_existing

cause

Get or set the "cause" attribute
is_date

Is the input a date?
bapply

Wrapper to vapply that returns booleans.
is_credit_card_number

Does the character vector contain credit card numbers?
is_connection

Is the input a connection?
has_any_attributes

Does the input have any attributes?
is_in_past

Is the input in the past/future?
has_dims

Does the input have dimensions?
is_error_free

is_cas_number

Does the character vector contain CAS registry numbers?
is_diagonal_matrix

Is the input a diagonal matrix?
changes

Important changes to assertive
is_complex

Is the input complex?
character_to_list_of_integer_vectors

is_data.frame

Is the input is a data.frame?
is_inherited_from

Does the object inherit from some class?
is_equal_to

How does the input relate to a value?
coerce_to

Coerce variable to a different class
is_environment

Is the input an environment?
assertive

Readable check functions to ensure code integrity.
is_qr

Is the input a QR decomposition of a matrix?
is_email_address

Does the character vector contain email addresses?
has_slot

Does the S4 input have a slot?
is_data.table

Is the input a data.table?
is2

Alternative version of is
assert_is_all_of

Does x belong to these classes?
has_duplicates

Does the input have duplicates?
is_factor

Is the input a factor?
is_package_current

Is the installed version of a package current?
are_set_equal

Set comparisons
is_raster

Is the input a raster?
false

FALSE, with a cause of failure
Truth

Is the input TRUE/FALSE/NA?
is_logical

Is the input logical?
assertionError

Condition classes
is_if_condition

is_binding_locked

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
is_executable_file

Is the file accessible?
is_isbn_code

Does the character vector contain ISBN book codes?
is_null

Checks to see if the input is (not) null.
is_empty

Is the input empty/scalar?
is_lower_triangular_matrix

Is the matrix upper/lower triangular?
dont_stop

Run code without stopping
is_empty_model

Is the input the empty model?
is_empty_file

Is a file empty?
is_function

Is the input a function?
is_in_range

Is the input in range?
has_names

Does the input have names?
assert_engine

Throws an error if a condition isn't met
is_identity_matrix

Is the input an identity matrix?
is_list

Is the input a list?
is_batch_mode

How is R running?
is_numeric

Is the input numeric?
is_library

Is the directory a known R library?
is_honorific

Is the string an honorific?
is_numeric_string

is_r

Are you running R?
is_raw

Is the input raw?
is_try_error

Is the input a condition?
strip_attributes

Strip all attributes from a variable
is_nan

Is the input (not) NaN?
is_existing_file

Does the file exist?
set_cause

Set a cause and return the input
is_on_os_path

Is the path on the OS path?
is_tbl

Is the input a tbl?
is_table

Is the input a table?
is_ip_address

Does the character vector contain IP addresses?
is_ts

Is the input a time series?
is_loaded

is_windows

What OS is running?
is_integer

Is the input an integer?
is_whole_number

Is the input a whole number?
is_rstudio_desktop

Is RStudio running in desktop or server mode?
n_elements

Get the number of elements
r_has_jpeg_capability

Does R have a capability?
is_square_matrix

Is the input a square matrix?
is_us_zip_code

Is the string a valid US zip code?
is_uk_national_insurance_number

Is the string a valid UK national insurance number?
is_us_social_security_number

Is the string a valid US SSN?
is_formula

Is the input a formula?
is_rstudio_current

Is RStudio the current version?
sys_get_locale

Get or set the system locale
is_relistable

Is the input relistable?
is_symmetric_matrix

Is the input a symmetric matrix?
is_unsorted

Is the input unsorted?
use_first

Only use the first element of a vector
is_single_character

is_uk_telephone_number

Is the string a valid UK telephone number?
is_uk_car_licence

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

Merge ellipsis args with a list.
is_s4

Is the input an S4 object?
is_us_telephone_number

Is the string a valid US telephone number?
na

NA, with a cause of failure
r_can_find_tools

Can R find tools?
is_zero_matrix

Is the input a zero matrix?
is_uk_postcode

Is the string a valid UK postcode?
is_valid_variable_name

parenthesize

Wrap a string in brackets
is_valid_r_code