EVOLUTION-MANAGER
Edit File: print.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: Print Values</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 print {base}"><tr><td>print {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Print Values</h2> <h3>Description</h3> <p><code>print</code> prints its argument and returns it <em>invisibly</em> (via <code><a href="invisible.html">invisible</a>(x)</code>). It is a generic function which means that new printing methods can be easily added for new <code><a href="class.html">class</a></code>es. </p> <h3>Usage</h3> <pre> print(x, ...) ## S3 method for class 'factor' print(x, quote = FALSE, max.levels = NULL, width = getOption("width"), ...) ## S3 method for class 'table' print(x, digits = getOption("digits"), quote = FALSE, na.print = "", zero.print = "0", right = is.numeric(x) || is.complex(x), justify = "none", ...) ## S3 method for class 'function' print(x, useSource = TRUE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>an object used to select a method.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments passed to or from other methods.</p> </td></tr> <tr valign="top"><td><code>quote</code></td> <td> <p>logical, indicating whether or not strings should be printed with surrounding quotes.</p> </td></tr> <tr valign="top"><td><code>max.levels</code></td> <td> <p>integer, indicating how many levels should be printed for a factor; if <code>0</code>, no extra "Levels" line will be printed. The default, <code>NULL</code>, entails choosing <code>max.levels</code> such that the levels print on one line of width <code>width</code>.</p> </td></tr> <tr valign="top"><td><code>width</code></td> <td> <p>only used when <code>max.levels</code> is NULL, see above.</p> </td></tr> <tr valign="top"><td><code>digits</code></td> <td> <p>minimal number of <em>significant</em> digits, see <code><a href="print.default.html">print.default</a></code>.</p> </td></tr> <tr valign="top"><td><code>na.print</code></td> <td> <p>character string (or <code>NULL</code>) indicating <code><a href="NA.html">NA</a></code> values in printed output, see <code><a href="print.default.html">print.default</a></code>.</p> </td></tr> <tr valign="top"><td><code>zero.print</code></td> <td> <p>character specifying how zeros (<code>0</code>) should be printed; for sparse tables, using <code>"."</code> can produce more readable results, similar to printing sparse matrices in <a href="https://CRAN.R-project.org/package=Matrix"><span class="pkg">Matrix</span></a>.</p> </td></tr> <tr valign="top"><td><code>right</code></td> <td> <p>logical, indicating whether or not strings should be right aligned.</p> </td></tr> <tr valign="top"><td><code>justify</code></td> <td> <p>character indicating if strings should left- or right-justified or left alone, passed to <code><a href="format.html">format</a></code>.</p> </td></tr> <tr valign="top"><td><code>useSource</code></td> <td> <p>logical indicating if internally stored source should be used for printing when present, e.g., if <code><a href="options.html">options</a>(keep.source = TRUE)</code> has been in use.</p> </td></tr> </table> <h3>Details</h3> <p>The default method, <code><a href="print.default.html">print.default</a></code> has its own help page. Use <code><a href="../../utils/html/methods.html">methods</a>("print")</code> to get all the methods for the <code>print</code> generic. </p> <p><code>print.factor</code> allows some customization and is used for printing <code><a href="factor.html">ordered</a></code> factors as well. </p> <p><code>print.table</code> for printing <code><a href="table.html">table</a></code>s allows other customization. As of R 3.0.0, it only prints a description in case of a table with 0-extents (this can happen if a classifier has no valid data). </p> <p>See <code><a href="noquote.html">noquote</a></code> as an example of a class whose main purpose is a specific <code>print</code> method. </p> <h3>References</h3> <p>Chambers, J. M. and Hastie, T. J. (1992) <em>Statistical Models in S.</em> Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p>The default method <code><a href="print.default.html">print.default</a></code>, and help for the methods above; further <code><a href="options.html">options</a></code>, <code><a href="noquote.html">noquote</a></code>. </p> <p>For more customizable (but cumbersome) printing, see <code><a href="cat.html">cat</a></code>, <code><a href="format.html">format</a></code> or also <code><a href="write.html">write</a></code>. For a simple prototypical print method, see <code><a href="../../tools/html/.print.via.format.html">.print.via.format</a></code> in package <span class="pkg">tools</span>. </p> <h3>Examples</h3> <pre> require(stats) ts(1:20) #-- print is the "Default function" --> print.ts(.) is called for(i in 1:3) print(1:i) ## Printing of factors attenu$station ## 117 levels -> 'max.levels' depending on width ## ordered factors: levels "l1 < l2 < .." esoph$agegp[1:12] esoph$alcgp[1:12] ## Printing of sparse (contingency) tables set.seed(521) t1 <- round(abs(rt(200, df = 1.8))) t2 <- round(abs(rt(200, df = 1.4))) table(t1, t2) # simple print(table(t1, t2), zero.print = ".") # nicer to read ## same for non-integer "table": T <- table(t2,t1) T <- T * (1+round(rlnorm(length(T)))/4) print(T, zero.print = ".") # quite nicer, print.table(T[,2:8] * 1e9, digits=3, zero.print = ".") ## still slightly inferior to Matrix::Matrix(T) for larger T ## Corner cases with empty extents: table(1, NA) # < table of extent 1 x 0 > </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>