Load or Save or Display the Commands History
Load or save or display the commands history.
loadhistory(file = ".Rhistory") savehistory(file = ".Rhistory")
history(max.show = 25, reverse = FALSE, pattern, ...)
timestamp(stamp = date(), prefix = "##------ ", suffix = " ------##", quiet = FALSE)
- 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.
Infwill give all of the currently available history.
- 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
grepwhen doing the matching.
- 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.
TRUE, suppress printing timestamp to the console.
There are several history mechanisms available for the different Rconsoles, which work in similar but not identical ways. There are separate versions of this help file for Unix and Windows.
The functions described here work in
The history mechanism is
The functions described here work on Unix-alikes under the
readline command-line interface but may not otherwise (for
example, in batch use or in an embedded application). Note that Rcan be built without
readline history mechanism
is controlled by two environment variables:
savehistory). There is no limit on the
number of lines of history retained during a session, so setting
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.
## Save the history in the home directory: note that it is not ## (by default) read from there but from the current directory .Last <- function() if(interactive()) try(savehistory("~/.Rhistory"))