print()

print(x, ...)
Returns: any · Updated March 13, 2026 · Base Functions
output base print

print() displays R objects in the console or an output connection. It is a generic function with methods for vectors, data frames, lists, matrices, and many other object types.

Syntax

print(x, ...)

Parameters

ParameterTypeDefaultDescription
xobjectAn object to print
...argumentsAdditional arguments passed to methods
digitsintegerNULLNumber of significant digits
quotelogicalFALSEWhether to quote string output
print.gapintegerNULLSpacing for matrix/array output

Examples

Basic usage

# Print a vector
x <- c(1, 2, 3)
print(x)
# [1] 1 2 3

# Print a data frame
df <- data.frame(name = c("Alice", "Bob"), age = c(25, 30))
print(df)
#   name age
# 1 Alice  25
# 2   Bob  30

Controlling output

# Print with more digits
pi_values <- c(pi, pi^2, pi^3)
print(pi_values, digits = 5)
# [1]  3.1416  9.8696 31.0063

# Quote strings in output
words <- c("hello", "world")
print(words, quote = TRUE)
# [1] "hello" "world"

Common Patterns

  • Use print() inside functions to debug values
  • Set digits for consistent numeric precision
  • Use cat() for simpler output without row numbers

See Also