Checklists of checks
How to use this vignette
Find the section related to your variable type or use case, run through the checklist to help you think about what state your variable should be in, then add some assertions to your code.
Checks for all argument types
- Is the variable the correct type? (
is_numeric
,is_character
,is_data.frame
,coerce_to
, etc.) - Is the variable the correct size? (
is_scalar
,is_empty
,is_non_empty
,use_first
,has_dims
,DIM
, etc.) - Are missing values allowed? (
is_na
,is_not_na
) - Is
NULL
allowed? (is_null
,is_not_null
) - Are duplicate values allowed? (
has_duplicates
,has_no_duplicates
) - Are attributes allowed? (
has_any_attributes
)
Checks for numeric arguments
- Are finite/infinite/NaN values allowed? (
is_finite
,is_infinite
,is_nan
,is_not_nan
, etc.). - Are the values in range? (
is_in_range
,is_positive
,is_percentage
, etc.) - Are complex numbers allowed? (
is_complex
,is_real
,is_imaginary
) - Are the values whole numbers? (
is_whole_number
,is_integer
) - Should the values be divisible by something? (
is_divisible_by
,is_even
,is_odd
)
Checks for character arguments
- Are empty strings allowed? (
is_empty_character
,is_missing_or_empty_character
,is_not_missing_nor_empty_character
) - Do you actually want a factor? (
is_factor
, andbase::factor
) - Does the string represent a complex data type? (
is_email_address
,is_credit_card_number
,is_uk_postcode
,is_us_zip_code
, and many more) - Does the string represent R code? (
is_valid_variable_name
,is_valid_r_code
)
Checks for working with files
- Does the path represent an existing file or dir? (
is_existing_file
,is_dir
) - Do you have permission to read/write/execute to that location?
(
is_readable_file
,is_writable_file
,is_executable_file
) - Is your file connection readable/writable? (
is_readable_connection
,is_writable_connection
) - Which operating system am I using? (
is_windows
,is_linux
,is_mac
,is_solaris
,is_unix
) - Does the current working dir have an effect? (
standardize_path
inpathological
,in_dir
indevtools
) - Does the operating system
PATH
environment variable have an effect? (is_on_os_path
) - Can R create that plot file type? (
r_has_png_capability
,r_has_jpeg_capability
,r_has_tiff_capability
)