REPL

R comes with a full-featured interactive command-line REPL (read-eval-print loop) built into theR executable. In addition to allowing quick and easy evaluation of R statements, it has a searchable history, tab-completion, many helpful keybindings, and dedicated help ? and shell modes ;.

This page provides examples of using REPL on the command line.

R REPL Example

  • Type "module load r" in terminal to load the R module, then on a new line type "R" to launch R

  • In terminal, q() quits the R module

Terminal screen with R launched. > "Hello, World!" Output = "Hello, World!"; > word = "test" > typeof(word) Output = "character"; >nchar(word) Output = 4; >print(word) Output = "test"; > q()

R REPL Help Pages

  • Type "?" or help(function) to enter help pages within R's REPL

  • For example, to ask for help with linear functions in R, use help(lm) (output shown below)

Terminal screen with R launched. Output of command help(lm)

Resources

Last updated