inbra: Paste objects between brackets

Description Usage Arguments Details Value See Also Examples

View source: R/statTools_code_OTHER.R

Description

The first element is placed outside brackets and the rest inside. In de form of before (inside1, inside2, ...)

Usage

1
2
inbra(before, ..., between = "-", add = "",
  rounding = getOption("rounding"))

Arguments

before

Vector with the values written before the bracket starts. It can also be a data frame or matrix (see Details).

...

Other vectors to be displayed between brackets.

between

Defaults to "-". Character vector with the strings to separate values inside the brackets. If it has length 1, it is replicated for all elements.

add

Defaults to "". A character vector with strings to add after every value inside the brackets. If it has length 1, it is replicated for all elements.

rounding

Defaults to getOption("rounding"). Number of decimals used for rounding. See digits from round.

Details

When before is a data frame, it returns a vector of strings where the first column from the data frame is outside the brackets and all the others inside separated by the symbol given in between. When before is a vector and ... are also vectors of the same length, a data frame is created and the same that above is performed.

Value

Returns a vector of strings with the values before and between the brackets. Has an attribute named data.frame with the values used.

See Also

bivarTable

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
mins <- apply(iris[1:4], 2, min)
maxs <- apply(iris[1:4], 2, max)
means <- apply(iris[1:4], 2, mean)
inbra(means, mins, maxs, between = " to ")

freqs <- as.numeric(table(iris$Species))
percents <- as.numeric(100*prop.table(table(iris$Species)))
inbra(freqs, percents, rounding = 2, add = "%")

# with a data frame:
values <- inbra(iris[c(5, 1:4)], between = c("; ", " - ", " - "), add = "cm")
values

# data arguments are still stored in
attributes(values)$data

gcastella/statTools documentation built on May 16, 2019, 11:10 p.m.