Package 'toscmask'

Title: Improved Versions of Base Functions
Description: Operators and functions provided by base R sometimes lack some features found in other programming languages, such as the ability to concatenate strings using + or to repeat strings using *. This package aims at providing such functionality without breaking existing code, i.e., only statements, that would throw errors in pure base R are patched.
Authors: Tobias Schmidt [aut, cre]
Maintainer: Tobias Schmidt <[email protected]>
License: MIT + file LICENSE
Version: 1.2.3
Built: 2024-11-01 11:17:32 UTC
Source: https://github.com/toscm/toscmask

Help Index


Plus operator

Description

Behaves like normal + except for character vectors combinations of character and numeric vectors, which are pasted together.

Usage

x + y

Arguments

x, y

numeric or complex vectors or objects which can be coerced to such, or other objects for which methods have been written, or a combination of numeric and character vectors.

Value

Same as +, except if e1 and e2 are two character vectors or a combination of a character vector and a numeric vector, in this case the result is paste0(x, y).

Examples

"abc" + "def"
"abc" + 1.234
1.234 + "abc"
"abc" + 2L
2L + "abc"

Star operator

Description

Behaves like normal * except if one operand is numeric and the other operand is of type character. In that case, each element of the character vector is replicated and the replicates are pasted together.

Usage

x * y

Arguments

x, y

numeric or complex vectors or objects which can be coerced to such, or other objects for which methods have been written, or a combination of numeric and character vectors.

Value

Same as *, except if one operand is numeric and the other operand is of type character. In that case, each element of the character vector is replicated, the replicates are pasted together and the result is returned.

Examples

"a" * 3
c("a", "b") * 3
3 * "a"
3 * c("a", "b")