Lesson 1 of 16

Hello, World!

Your First R Program

The simplest way to print output in R is the cat() function:

cat("Hello, World!\n")

The \n at the end adds a newline character. Unlike print(), cat() outputs raw text without quotes or line numbers.

Comments

Comments in R start with #:

# This is a comment
cat("Hello\n")  # This is also a comment

cat() vs print()

R has two main output functions:

FunctionDescription
cat()Outputs raw text, no quotes, no newline unless you add \n
print()Outputs a formatted representation with [1] prefix and quotes for strings

Throughout this course, we use cat() for predictable output formatting.

Your Task

Write a program that prints exactly Hello, World! followed by a newline.

R runtime loading...
Loading...
Click "Run" to execute your code.