How to Print Data in R

03.19.2021

Printing data in R is pretty straight forward. In this article, we will show you two functions that are built in to R that will print data to the console print and cat.

For those of you who are here to copy the code, here it is. Read on for more details.

print("Printing a string")
print(2)


cat("Let's print", 2, "or more values")

As shown above, we have two options. The first is the print funciton. We can pass any data type to the print function and R will display that in the console.

print("a string")
print(2)
print(c(1, 2, 3, 4, 5))

However, the print statement can only print one variable at a time. If we want to print multiple, we can use the cat method.

cat("a string", 2, c(1, 2, 3, 4, 5))