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:
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
x <- 42
print(x)
y <- x * 2
print(y)
Login to try C/C++/Java/PHP code in the editor
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
- Typing a command and forgetting the closing bracket or quote, leaving the console on a
+continuation prompt; press Esc to cancel. - Assuming variables saved in the console persist after closing R, when the workspace is lost unless you save it.
- Typing
x = 5in the console and expectingx <- 5behaviour 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: