R print()

KyraThompson's avatar
Published Oct 7, 2022
Contribute to Docs

The print() function prints out the specified argument.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn how to code and clean and manipulate data for analysis and visualization with the R programming language.
    • Beginner Friendly.
      14 hours

Syntax

print(argument)

The argument to be printed is of a valid data type.

Example

The following example prints out a data frame with the print() function:

school_teams <- data.frame(Sport = c("Basketball", "Baseball", "Football", "Track", "Tennis", "Swim"), Coach = c("Tyler", "Blake", "Stephanie", "Jordan", "Taylor","Brooklyn"), Player_Count = c(15, 24, 22, 20, 12, 29))
print(school_teams)

This outputs the following:

Sport Coach Player_Count
1 Basketball Tyler 15
2 Baseball Blake 24
3 Football Stephanie 22
4 Track Jordan 20
5 Tennis Taylor 12
6 Swim Brooklyn 29

All contributors

Contribute to Docs

Learn R on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn how to code and clean and manipulate data for analysis and visualization with the R programming language.
    • Beginner Friendly.
      14 hours