Assertions to Check Properties of Files

A set of predicates and assertions for checking the properties of files and connections. 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.

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

A set of predicates and assertions for checking the files of variables, such as length, names and attributes. Most of the documentation is on the assertive page. End-users will usually want to use assertive directly.


To install the stable version, type:


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


Then you can install the assertive.files package using



Functions for files:

is_dir checks if a path corresponds to a directory.

is_empty_file checks if a path corresponds to an empty file.

is_existing_file checks if a path corresponds to an existing file.

is_readable_file, is_writable_file, and is_executable_file check a file's permissions. (Though they are based upon base::file.access, which sometimes gives unexpected results under Windows.)

is_library checks if a path corresponds to a library that R knows about.

Functions for connections:

is_connection checks if a variable is a connection.

is_bzfile_connection, is_fifo_connection, is_file_connection, is_gzfile_connection, is_pipe_connection, is_socket_connection, is_terminal_connection, is_text_connection, is_unz_connection, and is_url_connection check for these specific connection types.

is_stderr, is_stdin, and is_stdout check for these standard connections.

is_incomplete_connection, is_open_connection, is_readable_connection, and is_writable_connection check for these properties of connections.


Predicates that return a vector have two corresponding assertions. For example, is_dir has assert_all_are_dirs and assert_any_are_dirs.

Predicates returning a single logical value have one corresponding assertion. For example, is_stdin has assert_is_stdin.


0.0-2 Added is_file_size_in_range. Can turn off warning about file.access under Windows. 0.0-1 Content extracted from assertive 0.3-0, and tidied.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.0-2 by Richard Cotton, 3 years ago

Report a bug at

Browse source code at

Authors: Richard Cotton [aut, cre]

Documentation:   PDF Manual  

GPL (>= 3) license

Imports assertive.base, assertive.numbers

Suggests testthat

Imported by assertive, flippant, multipanelfigure, pathological, poio.

See at CRAN