| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/helpers.R |
| 3 |
\name{p} |
| 4 |
\alias{p} |
| 5 |
\title{Inline Printing} |
| 6 |
\usage{ |
| 7 |
p( |
| 8 |
x, |
| 9 |
wrap = panderOptions("p.wrap"), |
| 10 |
sep = panderOptions("p.sep"), |
| 11 |
copula = panderOptions("p.copula"), |
| 12 |
limit = Inf, |
| 13 |
keep.trailing.zeros = panderOptions("keep.trailing.zeros"), |
| 14 |
missing = panderOptions("missing"), |
| 15 |
digits = panderOptions("digits"), |
| 16 |
round = panderOptions("round") |
| 17 |
) |
| 18 |
} |
| 19 |
\arguments{ |
| 20 |
\item{x}{an atomic vector to get merged for inline printing} |
| 21 |
|
| 22 |
\item{wrap}{a string to wrap vector elements (uses value set in \code{p.wrap} option: \code{'_'} by default, which is a markdown-friendly wrapper and it puts the string in \emph{italic})} |
| 23 |
|
| 24 |
\item{sep}{a string with the main separator, i.e. the one that separates all vector elements but the last two (uses the value set in \code{p.sep} option - \code{','} by default)} |
| 25 |
|
| 26 |
\item{copula}{a string with ending separator - the one that separates the last two vector elements (uses the value set in \code{p.copula} option, \code{'and'} by default)} |
| 27 |
|
| 28 |
\item{limit}{maximum character length (defaults to \code{Inf}initive elements)} |
| 29 |
|
| 30 |
\item{keep.trailing.zeros}{to show or remove trailing zeros in numbers} |
| 31 |
|
| 32 |
\item{missing}{string to replace missing values} |
| 33 |
|
| 34 |
\item{digits}{numeric (default: 2) passed to format} |
| 35 |
|
| 36 |
\item{round}{numeric (default: Inf) passed to round} |
| 37 |
} |
| 38 |
\value{ |
| 39 |
a string with concatenated vector contents |
| 40 |
} |
| 41 |
\description{ |
| 42 |
\code{\link{p}} merges elements of a vector in one string for the sake of pretty inline printing. Default parameters are read from appropriate \code{option} values (see argument description for details). This function allows you to put the results of an expression that yields a variable \emph{inline}, by wrapping the vector elements with the string provided in \code{wrap}, and separating elements by main and ending separator (\code{sep} and \code{copula}). In case of a two-length vector, value specified in \code{copula} will be used as a separator. You can also control the length of provided vector by altering an integer value specified in \code{limit} argument (defaults to \code{Inf}). |
| 43 |
} |
| 44 |
\examples{ |
| 45 |
p(c('fee', 'fi', 'foo', 'fam')) |
| 46 |
# [1] '_fee_, _fi_, _foo_ and _fam_' |
| 47 |
p(1:3, wrap = '') |
| 48 |
# [1] '1, 2 and 3' |
| 49 |
p(LETTERS[1:5], copula = 'and the letter') |
| 50 |
# [1] '_A_, _B_, _C_, _D_ and the letter _E_' |
| 51 |
p(c('Thelma', 'Louise'), wrap = '', copula = '&') |
| 52 |
# [1] 'Thelma & Louise' |
| 53 |
} |
| 54 |
\references{ |
| 55 |
This function was moved from \code{rapport} package: \url{https://rapporter.github.io/rapport/}. |
| 56 |
} |
| 57 |
\author{ |
| 58 |
Aleksandar Blagotic |
| 59 |
} |