Skip to content
Learn Netverks

Lesson

Step 6/36 17% through track

hello-world-r

Hello, World in R

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Hello, World in R: the syntax, patterns, and safety habits you need before advancing in R.

Teams still ship Hello, World in R in R codebases—skipping it leaves gaps in debugging and code reviews.

You will apply Hello, World in R in contexts like: Research pipelines, Shiny dashboards, and statistical reporting.

Write R in the editor and click Run on server—the dev runner executes with Rscript; use print() or cat() and base R in playground snippets (tidyverse locally; LEARNING_RUNNER_ENABLED=true). Also use print() or cat(); install.packages() for dplyr/ggplot2 on your machine.

When you can explain the previous lesson's ideas without copying starter code.

Every R script can print output with print() or cat(). Unlike Python print(), cat() concatenates strings without adding quotes or newlines unless you include \n.

Minimal program

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

print() shows the value with default formatting. cat() is ideal for building output lines manually.

Script vs REPL

# script.R
print("Hello, World")

# REPL: type expressions at the > prompt

The playground runs scripts like Rscript script.R. The interactive console is great for exploration locally—similar to Python's REPL.

Important interview questions and answers

  1. Q: What prints text in R?
    A: print() and cat()—use cat for formatted strings without extra quoting.
  2. Q: Is a main function required?
    A: No—top-level statements run when the script executes; packages use if (interactive()) patterns locally.

Self-check

  1. Which function adds quotes around character output by default?
  2. What runs an .R file from the shell?

Tip: Use cat() when building formatted lines; print() when inspecting whole objects.

Interview prep

print vs cat?

print() shows object representation; cat() writes strings without default quoting.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • cat vs print?
  • Source script?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump