File: str_trunc.Rd

package info (click to toggle)
r-cran-stringr 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,032 kB
  • sloc: javascript: 11; sh: 9; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 936 bytes parent folder | download | duplicates (2)
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/trunc.R
\name{str_trunc}
\alias{str_trunc}
\title{Truncate a string to maximum width}
\usage{
str_trunc(string, width, side = c("right", "left", "center"), ellipsis = "...")
}
\arguments{
\item{string}{Input vector. Either a character vector, or something
coercible to one.}

\item{width}{Maximum width of string.}

\item{side, ellipsis}{Location and content of ellipsis that indicates
content has been removed.}
}
\value{
A character vector the same length as \code{string}.
}
\description{
Truncate a string to a fixed of characters, so that
\code{str_length(str_trunc(x, n))} is always less than or equal to \code{n}.
}
\examples{
x <- "This string is moderately long"
rbind(
  str_trunc(x, 20, "right"),
  str_trunc(x, 20, "left"),
  str_trunc(x, 20, "center")
)
}
\seealso{
\code{\link[=str_pad]{str_pad()}} to increase the minimum width of a string.
}