Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

strutil

Utility functions to treat characters


Description

Function %+% paste characters with other characters pairwise. Function %n% is used to repeat a character n time. Function numtostr converts numeric to a string in a nice format.

Usage

x %+% y
x %n% y
numtostr(x,nch,digits=4)

Arguments

x

Character vector or a numeric vector for numtostr functions

y

Character vector

nch

(Optionnal) length of the resulting character vector

digits

Number of digits in the resulting strings

Value

Function %+% is an operator that shortens paste(x, y, sep="") see help(paste) for more options. Function %n% returns the character vector x repeated y times. If both x and y are vector each element of x are applied to each element of y. Function numtostr converts numerical vector to a character vector using a nice format.

Author(s)

Charles-Édouard Giguère

Examples

require(CUFF)
"Hello " %+% "world."
cat(" " %n%  c(rep(1,9),2) %+% 1:10,fill=TRUE)
### Returns a * because specified length of character is unsufficient. 
numtostr(9048948449.94948,nch=8)

CUFF

Charles's Utility Function using Formula

v1.7
GPL (>= 2)
Authors
Charles-Édouard Giguère
Initial release
2020-09-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.