Learn R Programming

dtlg (version 0.0.2)

indent: Add indentation to strings

Description

indent() prefixes a string with a sequence of HTML non-breaking spaces, to effectively work as indentation.

Usage

indent(x, n = 4L, indentation = nbsp(n = n))

Value

A character vector of the same length as x.

Arguments

x

A character vector of strings to be indented.

n

Number of non-breaking spaces to use as indentation. If n = 0 then no indentation is performed.

indentation

As an alternative to the number of spaces n you may pass the actual sequence of HTML non-breaking spaces as a string to this parameter, or any other string for that matter. Defaults to an indentation of four spaces (n = 4).

Examples

Run this code
# Default is to indent by four non-breaking spaces.
indent("Mean")

# Choose a different indentation level.
indent("Mean", n = 2L)

# `indent()` is vectorised over `x`
indent(c("Mean", "Median", "Max, Min", "Missing"))

Run the code above in your browser using DataLab