nstr: Creates a string of arbitry length

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/nstr.s

Description

Creates a vector of strings which consists of the string segment given in each element of the string vector repeated times.

Usage

1
nstr(string, times)

Arguments

string

character: vector of string segments to be repeated. Will be recycled if argument times is longer.

times

integer: vector of number of times to repeat the corisponding segment. Will be recycled if argument string is longer.

Value

returns a character vector the same length as the longest of the two arguments.

Note

Will throw a warning if the length of the longer argment is not a even multiple of the shorter argument.

Author(s)

Charles Dupont

See Also

paste, rep

Examples

1
2
3
4
5
nstr(c("a"), c(0,3,4))

nstr(c("a", "b", "c"), c(1,2,3))

nstr(c("a", "b", "c"), 4)

Example output

Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package: 'Hmisc'

The following objects are masked from 'package:base':

    format.pval, units

[1] ""     "aaa"  "aaaa"
[1] "a"   "bb"  "ccc"
[1] "aaaa" "bbbb" "cccc"

Hmisc documentation built on Oct. 7, 2021, 9:16 a.m.