File: stri_flatten.Rd

package info (click to toggle)
r-cran-stringi 1.7.12-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 39,772 kB
  • sloc: cpp: 482,349; ansic: 51,900; perl: 471; makefile: 9; sh: 1
file content (62 lines) | stat: -rw-r--r-- 1,946 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/join.R
\name{stri_flatten}
\alias{stri_flatten}
\title{Flatten a String}
\usage{
stri_flatten(str, collapse = "", na_empty = FALSE, omit_empty = FALSE)
}
\arguments{
\item{str}{a vector of strings to be coerced to character}

\item{collapse}{a single string denoting the separator}

\item{na_empty}{single logical value; should missing values
in \code{str} be treated as empty strings (\code{TRUE})
or be omitted whatsoever (\code{NA})?}

\item{omit_empty}{single logical value; should empty strings
in \code{str} be omitted?}
}
\value{
Returns a single string, i.e., a character
vector of length 1.
}
\description{
Joins the elements of a character vector into one string.
}
\details{
The \code{stri_flatten(str, collapse='XXX')} call
is equivalent to \code{\link{paste}(str, collapse='XXX', sep='')}.

If you wish to use some more fancy (e.g., differing)
separators between flattened strings,
call \code{\link{stri_join}(str, separators, collapse='')}.

If \code{str} is not empty, then a single string is returned.
If \code{collapse} has length > 1, then only the first string
will be used.
}
\examples{
stri_flatten(LETTERS)
stri_flatten(LETTERS, collapse=',')
stri_flatten(stri_dup(letters[1:6], 1:3))
stri_flatten(c(NA, '', 'A', '', 'B', NA, 'C'), collapse=',', na_empty=TRUE, omit_empty=TRUE)
stri_flatten(c(NA, '', 'A', '', 'B', NA, 'C'), collapse=',', na_empty=NA)

}
\seealso{
The official online manual of \pkg{stringi} at \url{https://stringi.gagolewski.com/}

Gagolewski M., \pkg{stringi}: Fast and portable character string processing in R, \emph{Journal of Statistical Software} 103(2), 2022, 1-59, \doi{10.18637/jss.v103.i02}

Other join: 
\code{\link{\%s+\%}()},
\code{\link{stri_dup}()},
\code{\link{stri_join_list}()},
\code{\link{stri_join}()}
}
\concept{join}
\author{
\href{https://www.gagolewski.com/}{Marek Gagolewski} and other contributors
}