EVOLUTION-MANAGER
Edit File: str_glue.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: Format and interpolate a string with glue</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_glue {stringr}"><tr><td>str_glue {stringr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Format and interpolate a string with glue</h2> <h3>Description</h3> <p>These functions are wrappers around <code><a href="../../glue/html/glue.html">glue::glue()</a></code> and <code><a href="../../glue/html/glue_data.html">glue::glue_data()</a></code>, which provide a powerful and elegant syntax for interpolating strings. These wrappers provide a small set of the full options. Use the functions directly from glue for more control. </p> <h3>Usage</h3> <pre> str_glue(..., .sep = "", .envir = parent.frame()) str_glue_data(.x, ..., .sep = "", .envir = parent.frame(), .na = "NA") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>[<code>expressions</code>]<br /> Expressions string(s) to format, multiple inputs are concatenated together before formatting.</p> </td></tr> <tr valign="top"><td><code>.sep</code></td> <td> <p>[<code>character(1)</code>: ‘""’]<br /> Separator used to separate elements.</p> </td></tr> <tr valign="top"><td><code>.envir</code></td> <td> <p>[<code>environment</code>: <code>parent.frame()</code>]<br /> Environment to evaluate each expression in. Expressions are evaluated from left to right. If <code>.x</code> is an environment, the expressions are evaluated in that environment and <code>.envir</code> is ignored.</p> </td></tr> <tr valign="top"><td><code>.x</code></td> <td> <p>[<code>listish</code>]<br /> An environment, list or data frame used to lookup values.</p> </td></tr> <tr valign="top"><td><code>.na</code></td> <td> <p>[<code>character(1)</code>: ‘NA’]<br /> Value to replace NA values with. If <code>NULL</code> missing values are propagated, that is an <code>NA</code> result will cause <code>NA</code> output. Otherwise the value is replaced by the value of <code>.na</code>.</p> </td></tr> </table> <h3>Examples</h3> <pre> name <- "Fred" age <- 50 anniversary <- as.Date("1991-10-12") str_glue( "My name is {name}, ", "my age next year is {age + 1}, ", "and my anniversary is {format(anniversary, '%A, %B %d, %Y')}." ) # single braces can be inserted by doubling them str_glue("My name is {name}, not {{name}}.") # You can also used named arguments str_glue( "My name is {name}, ", "and my age next year is {age + 1}.", name = "Joe", age = 40 ) # `str_glue_data()` is useful in data pipelines mtcars %>% str_glue_data("{rownames(.)} has {hp} hp") </pre> <hr /><div style="text-align: center;">[Package <em>stringr</em> version 1.4.0 <a href="00Index.html">Index</a>]</div> </body></html>