Learn R Programming

whapi (version 0.0.2)

whapi_trunc: Truncate long strings for logging

Description

Helper function to shorten long strings when printing to logs. If the input string exceeds max characters, it is truncated and suffixed with "... (truncated)".

Usage

whapi_trunc(x, max = 2000L)

Value

A character string, possibly truncated.

Arguments

x

A character string (or coercible to character).

max

Integer. Maximum number of characters to display (default: 2000).

Examples

Run this code
whapi_trunc("short text", max = 10)
whapi_trunc(paste(rep("a", 5000), collapse = ""), max = 20)

Run the code above in your browser using DataLab