← Back to R Course | Chapter 1: Getting Started | Lesson 5 of 6

print() and cat()

In this page:

  1. print() and cat()

print() and cat()

print() displays an R object using its formatted representation, including quotes around strings and type-specific formatting. cat() concatenates and prints its arguments as raw text with no quotes, and is often used for cleaner, more readable output. Both are the primary ways to produce output in an R script.

Note: Use cat() when you want clean, human-readable output; use print() to see an object's full, unambiguous representation.

Example: print() and cat()

markup
print("Hello, World!")
cat("Hello, World!\n")

x <- c(1, 2, 3)
print(x)
cat("Vector:", x, "\n")
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.