EVOLUTION-MANAGER
Edit File: str_c.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Join multiple strings into a single string.</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for str_c {stringr}"><tr><td>str_c {stringr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Join multiple strings into a single string.</h2> <h3>Description</h3> <p>Joins two or more vectors element-wise into a single character vector, optionally inserting <code>sep</code> between input vectors. If <code>collapse</code> is not <code>NULL</code>, it will be inserted between elements of the result, returning a character vector of length 1. </p> <h3>Usage</h3> <pre> str_c(..., sep = "", collapse = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>One or more character vectors. Zero length arguments are removed. Short arguments are recycled to the length of the longest. </p> <p>Like most other R functions, missing values are "infectious": whenever a missing value is combined with another string the result will always be missing. Use <code><a href="str_replace_na.html">str_replace_na()</a></code> to convert <code>NA</code> to <code>"NA"</code></p> </td></tr> <tr valign="top"><td><code>sep</code></td> <td> <p>String to insert between input vectors.</p> </td></tr> <tr valign="top"><td><code>collapse</code></td> <td> <p>Optional string used to combine input vectors into single string.</p> </td></tr> </table> <h3>Details</h3> <p>To understand how <code>str_c</code> works, you need to imagine that you are building up a matrix of strings. Each input argument forms a column, and is expanded to the length of the longest argument, using the usual recyling rules. The <code>sep</code> string is inserted between each column. If collapse is <code>NULL</code> each row is collapsed into a single string. If non-<code>NULL</code> that string is inserted at the end of each row, and the entire matrix collapsed to a single string. </p> <h3>Value</h3> <p>If <code>collapse = NULL</code> (the default) a character vector with length equal to the longest input string. If <code>collapse</code> is non-NULL, a character vector of length 1. </p> <h3>See Also</h3> <p><code><a href="../../base/html/paste.html">paste()</a></code> for equivalent base R functionality, and <code><a href="../../stringi/html/stri_join.html">stringi::stri_join()</a></code> which this function wraps </p> <h3>Examples</h3> <pre> str_c("Letter: ", letters) str_c("Letter", letters, sep = ": ") str_c(letters, " is for", "...") str_c(letters[-26], " comes before ", letters[-1]) str_c(letters, collapse = "") str_c(letters, collapse = ", ") # Missing inputs give missing outputs str_c(c("a", NA, "b"), "-d") # Use str_replace_NA to display literal NAs: str_c(str_replace_na(c("a", NA, "b")), "-d") </pre> <hr /><div style="text-align: center;">[Package <em>stringr</em> version 1.4.0 <a href="00Index.html">Index</a>]</div> </body></html>