[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  print: Print Values

##  Description

` print ` prints its argument and returns it _invisibly_ (via ` [ invisible
](/link/invisible?package=base&version=3.6.2) (x) ` ). It is a generic
function which means that new printing methods can be easily added for new ` [
class ](/link/class?package=base&version=3.6.2) ` es.

##  Usage

    
    
    print(x, …)
    
    # S3 method for factor
    print(x, quote = FALSE, max.levels = NULL,
          width = getOption("width"), …)
    
    # S3 method for 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 function
    print(x, useSource = TRUE, …)

##  Arguments

x

an object used to select a method.

…

further arguments passed to or from other methods.

quote

logical, indicating whether or not strings should be printed with surrounding
quotes.

max.levels

integer, indicating how many levels should be printed for a factor; if ` 0 ` ,
no extra "Levels" line will be printed. The default, ` NULL ` , entails
choosing ` max.levels ` such that the levels print on one line of width `
width ` .

width

only used when ` max.levels ` is NULL, see above.

digits

minimal number of _significant_ digits, see ` [ print.default
](/link/print.default?package=base&version=3.6.2) ` .

na.print

character string (or ` NULL ` ) indicating ` [ NA
](/link/NA?package=base&version=3.6.2) ` values in printed output, see ` [
print.default ](/link/print.default?package=base&version=3.6.2) ` .

zero.print

character specifying how zeros ( ` 0 ` ) should be printed; for sparse tables,
using ` "." ` can produce more readable results, similar to printing sparse
matrices in Matrix.

right

logical, indicating whether or not strings should be right aligned.

justify

character indicating if strings should left- or right-justified or left alone,
passed to ` [ format ](/link/format?package=base&version=3.6.2) ` .

useSource

logical indicating if internally stored source should be used for printing
when present, e.g., if ` [ options ](/link/options?package=base&version=3.6.2)
(keep.source = TRUE) ` has been in use.

##  Details

The default method, ` [ print.default
](/link/print.default?package=base&version=3.6.2) ` has its own help page. Use
` [ methods ](/link/methods?package=base&version=3.6.2) ("print") ` to get all
the methods for the ` print ` generic.

` print.factor ` allows some customization and is used for printing ` [
ordered ](/link/ordered?package=base&version=3.6.2) ` factors as well.

` print.table ` for printing ` [ table
](/link/table?package=base&version=3.6.2) ` 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).

See ` [ noquote ](/link/noquote?package=base&version=3.6.2) ` as an example of
a class whose main purpose is a specific ` print ` method.

##  References

Chambers, J. M. and Hastie, T. J. (1992) _Statistical Models in S._ Wadsworth
& Brooks/Cole.

##  See Also

The default method ` [ print.default
](/link/print.default?package=base&version=3.6.2) ` , and help for the methods
above; further ` [ options ](/link/options?package=base&version=3.6.2) ` , ` [
noquote ](/link/noquote?package=base&version=3.6.2) ` .

For more customizable (but cumbersome) printing, see ` [ cat
](/link/cat?package=base&version=3.6.2) ` , ` [ format
](/link/format?package=base&version=3.6.2) ` or also ` [ write
](/link/write?package=base&version=3.6.2) ` . For a simple prototypical print
method, see ` [ .print.via.format
](/link/.print.via.format?package=base&version=3.6.2&to=tools) ` in package
tools  .

##  Examples

[ Run