Skip to contents

check_stop() processes the input data (dat) to prepare a formatted version for use in error messages. It is especially useful for displaying parts of a vector or data frame in a readable format, ensuring that large datasets are truncated and not overly verbose in error messages.

Usage

check_stop(dat)

Arguments

dat

The data to be formatted. Can be a matrix, data frame, or vector.

Value

A character string formatted for use in error messages:

  • If the input is a matrix or data frame, the function returns the class of the object.

  • If the input is a vector:

  • A comma-separated string of the first few elements (up to 5) is returned, followed by ", ..." if there are more elements.

  • If the vector has fewer than 10 elements, all elements are displayed.

Examples

check_stop(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
#> [1] "1, 2, 3, 4, 5, ..."
check_stop(data.frame(a = 1:3, b = 4:6))
#> [1] "data.frame"
check_stop(c(1, 2, 3))
#> [1] "1, 2, 3"