bru: [+] Generate a string of repeated symbols

Description Usage Arguments Value Author(s) See Also Examples

View source: R/bru.R

Description

Generate a string of repeated symbols. Useful for R Markdown (.rmd) files and console output to highlight results.

bru prints the string. Use bru to print the string directly to console or in R Markdown reports.
bru0 returns a string. Use bru0 in combination with functions such as sprintf.

Usage

1
2
3
4
5
6
7
8
9
bru(
  symbol = "=",
  n = 60,
  after = (if (print) 1 else 0),
  before = 0,
  print = TRUE
)

bru0(..., print = FALSE)

Arguments

symbol

A symbol or sequence of symbols to be used. Default is "=".

n

A number of symbols to return: a length of a string. Default is 60 symbols.

after

A number of new (empty) lines/rows to be added afterwards. 0 means that following text continues in the same row. Default is
if (print==TRUE) 1 else 0.

before

A number of peceeding (empty) rows to be added. Default is 0.

print

If TRUE (default for bru), result is printed to console using cat method. If FALSE, a string is returned.

...

(The same parameters as above).

Value

String of repeated symbols.

Author(s)

Vilmantas Gegzna

See Also

Other spMisc utilities: clc(), clear(), fCap(), isFALSE(), list_AddRm(), make.filenames(), open_wd(), printDuration(), regexp2df(), st01()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
library(spMisc)

bru()
## ============================================================

bru("-")
## ------------------------------------------------------------

bru("= ")
## = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

bru(12345, 3) # length = 3 symbols
## 123

bru(12345, 6) # length = 6 symbols
## 123451

bru0() # return a string
## [1] "============================================================"

# Several sequences in separate rows
bru(n=5);bru("*",n=5)
## =====
## *****

# Several sequences in one row
bru(n=5, after=0);bru("*",n=5, after=0)
## =====*****

# The same as previous, just short name of "after"
bru(n=5, a=0);bru("*",n=5, a=0)
## =====*****


paste(bru(":", 5),  bru("*", 5))
## :::::
## *****
## character(0)

paste(bru0(":", 5),  bru0("*", 5))
## [1] "::::: *****"

bru0('*', 10, before = 5)
## [1] "\n\n\n\n\n**********"

bru('*', 10, before = 5) # 5 empty rows are added
##
##
##
##
##
## **********

GegznaV/spMisc documentation built on April 26, 2020, 5:59 p.m.