EVOLUTION-MANAGER
Edit File: stri_list2matrix.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: Convert a List to a Character Matrix</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 stri_list2matrix {stringi}"><tr><td>stri_list2matrix {stringi}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Convert a List to a Character Matrix</h2> <h3>Description</h3> <p>This function converts a given list of atomic vectors to a character matrix. </p> <h3>Usage</h3> <pre> stri_list2matrix(x, byrow = FALSE, fill = NA_character_, n_min = 0) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a list of atomic vectors</p> </td></tr> <tr valign="top"><td><code>byrow</code></td> <td> <p>a single logical value; should the resulting matrix be transposed?</p> </td></tr> <tr valign="top"><td><code>fill</code></td> <td> <p>a single string, see Details</p> </td></tr> <tr valign="top"><td><code>n_min</code></td> <td> <p>a single integer value; minimal number of rows (<code>byrow==FALSE</code>) or columns (otherwise) in the resulting matrix</p> </td></tr> </table> <h3>Details</h3> <p>This function is similar to the built-in <code><a href="../../base/html/lapply.html">simplify2array</a></code> function. However, it always returns a character matrix, even if each element in <code>x</code> is of length 1 or if elements in <code>x</code> are not of the same lengths. Moreover, the elements in <code>x</code> are always coerced to character vectors. </p> <p>If <code>byrow</code> is <code>FALSE</code>, then a matrix with <code>length(x)</code> columns is returned. The number of rows is the length of the longest vector in <code>x</code>, but no less than <code>n_min</code>. Basically, we have <code>result[i,j] == x[[j]][i]</code> if <code>i <= length(x[[j]])</code> and <code>result[i,j] == fill</code> otherwise, see Examples. </p> <p>If <code>byrow</code> is <code>TRUE</code>, then the resulting matrix is a transposition of the above-described one. </p> <p>This function may be useful, e.g., in connection with <code><a href="stri_split.html">stri_split</a></code> and <code><a href="stri_extract.html">stri_extract_all</a></code>. </p> <h3>Value</h3> <p>Returns a character matrix. </p> <h3>See Also</h3> <p>Other utils: <code><a href="stri_na2empty.html">stri_na2empty</a>()</code>, <code><a href="stri_remove_empty.html">stri_remove_empty</a>()</code>, <code><a href="stri_replace_na.html">stri_replace_na</a>()</code> </p> <h3>Examples</h3> <pre> simplify2array(list(c("a", "b"), c("c", "d"), c("e", "f"))) stri_list2matrix(list(c("a", "b"), c("c", "d"), c("e", "f"))) stri_list2matrix(list(c("a", "b"), c("c", "d"), c("e", "f")), byrow=TRUE) simplify2array(list("a", c("b", "c"))) stri_list2matrix(list("a", c("b", "c"))) stri_list2matrix(list("a", c("b", "c")), fill="") stri_list2matrix(list("a", c("b", "c")), fill="", n_min=5) </pre> <hr /><div style="text-align: center;">[Package <em>stringi</em> version 1.4.6 <a href="00Index.html">Index</a>]</div> </body></html>