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

The R Console

The R console is a chat window where you type a command and R answers right away. It is like a calculator that also understands words.

In this page:

  1. The R Console

The R Console

The R console is an interactive prompt where you type expressions and see results immediately, useful for quick exploration before writing a full script.

Every complete expression you enter is evaluated and its value printed automatically at the console (though not inside a script). Scripts, by contrast, need explicit print() or cat() calls to show output.

Note: At the interactive console, just typing a variable's name prints its value -- but inside a script you must call print() explicitly.

Example: The R Console

markup
x <- 42
print(x)

y <- x * 2
print(y)
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Typing a command and forgetting the closing bracket or quote, leaving the console on a + continuation prompt; press Esc to cancel.
  2. Assuming variables saved in the console persist after closing R, when the workspace is lost unless you save it.
  3. Typing x = 5 in the console and expecting x <- 5 behaviour in every context, when arguments inside function calls treat = differently.
🔒

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.