Load or save or display the commands history.
1 2 3 4 5 6 7 8
The name of the file in which to save the history, or from which to load it. The path is relative to the current working directory.
The maximum number of lines to show.
logical. If true, the lines are shown in reverse order. Note: this is not useful when there are continuation lines.
A character string to be matched against the lines of the history. When supplied, only unique matching lines are shown.
Arguments to be passed to
A value or vector of values to be written into the history.
A prefix to apply to each line.
A suffix to apply to each line.
There are several history mechanisms available for the different R consoles, which work in similar but not identical ways. Notably, there are different implementations for Unix and Windows.
The functions described here work in
Rgui and interactive
Rterm but not in batch use of
Rterm nor in
The functions described here work under the
readline command-line interface but may not otherwise (for
example, in batch use or in an embedded application). Note that R
can be built without
R.app, the console on macOS, has a separate and largely
incompatible history mechanism, which by default uses a file
‘.Rapp.history’ and saves up to 250 entries. These functions are
not currently implemented there.
readline on Unix-alikes) history mechanism
is controlled by two environment variables: R_HISTSIZE controls
the number of lines that are saved (default 512), and R_HISTFILE
(default ‘.Rhistory’) sets the filename used for the
loading/saving of history if requested at the beginning/end of a
session (but not the default for
savehistory). There is no limit on the
number of lines of history retained during a session, so setting
R_HISTSIZE to a large value has no penalty unless a large file
is actually generated.
These environment variables are read at the time of saving, so can be
altered within a session by the use of
readline history library saves files with permission
0600, that is with read/write permission for the user and not
even read permission for any other account.
timestamp function writes a timestamp (or other message)
into the history and echos it to the console. On platforms that do not
support a history mechanism only the console message is printed.
If you want to save the history at the end of (almost) every
interactive session (even those in which you do not save the
workspace), you can put a call to
.Last. See the examples.
1 2 3 4 5 6 7
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.