EVOLUTION-MANAGER
Edit File: savehistory.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Load or Save or Display the Commands History</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for savehistory {utils}"><tr><td>savehistory {utils}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Load or Save or Display the Commands History</h2> <h3>Description</h3> <p>Load or save or display the commands history. </p> <h3>Usage</h3> <pre> loadhistory(file = ".Rhistory") savehistory(file = ".Rhistory") history(max.show = 25, reverse = FALSE, pattern, ...) timestamp(stamp = date(), prefix = "##------ ", suffix = " ------##", quiet = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>file</code></td> <td> <p>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.</p> </td></tr> <tr valign="top"><td><code>max.show</code></td> <td> <p>The maximum number of lines to show. <code>Inf</code> will give all of the currently available history.</p> </td></tr> <tr valign="top"><td><code>reverse</code></td> <td> <p>logical. If true, the lines are shown in reverse order. Note: this is not useful when there are continuation lines.</p> </td></tr> <tr valign="top"><td><code>pattern</code></td> <td> <p>A character string to be matched against the lines of the history. When supplied, only <em>unique</em> matching lines are shown.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Arguments to be passed to <code><a href="../../base/html/grep.html">grep</a></code> when doing the matching.</p> </td></tr> <tr valign="top"><td><code>stamp</code></td> <td> <p>A value or vector of values to be written into the history.</p> </td></tr> <tr valign="top"><td><code>prefix</code></td> <td> <p>A prefix to apply to each line.</p> </td></tr> <tr valign="top"><td><code>suffix</code></td> <td> <p>A suffix to apply to each line.</p> </td></tr> <tr valign="top"><td><code>quiet</code></td> <td> <p>If <code>TRUE</code>, suppress printing timestamp to the console.</p> </td></tr> </table> <h3>Details</h3> <p>There are several history mechanisms available for the different <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> consoles, which work in similar but not identical ways. Notably, there are different implementations for Unix and Windows. </p> <dl> <dt>Windows:</dt><dd> <p>The functions described here work in <code>Rgui</code> and interactive <code>Rterm</code> but not in batch use of <code>Rterm</code> nor in embedded/DCOM versions. </p> </dd> <dt>Unix-alikes:</dt><dd> <p>The functions described here work under the <code>readline</code> command-line interface but may not otherwise (for example, in batch use or in an embedded application). Note that <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> can be built without <code>readline</code>. </p> <p><code>R.app</code>, the console on macOS, has a separate and largely incompatible history mechanism, which by default uses a file ‘<span class="file">.Rapp.history</span>’ and saves up to 250 entries. These functions are not currently implemented there. </p> </dd> </dl> <p>The (<code>readline</code> on Unix-alikes) history mechanism is controlled by two environment variables: <span class="env">R_HISTSIZE</span> controls the number of lines that are saved (default 512), and <span class="env">R_HISTFILE</span> (default ‘<span class="file">.Rhistory</span>’) sets the filename used for the loading/saving of history if requested at the beginning/end of a session (but not the default for <code>loadhistory</code>/<code>savehistory</code>). There is no limit on the number of lines of history retained during a session, so setting <span class="env">R_HISTSIZE</span> to a large value has no penalty unless a large file is actually generated. </p> <p>These environment variables are read at the time of saving, so can be altered within a session by the use of <code><a href="../../base/html/Sys.setenv.html">Sys.setenv</a></code>. </p> <p>On Unix-alikes: Note that <code>readline</code> history library saves files with permission <code>0600</code>, that is with read/write permission for the user and not even read permission for any other account. </p> <p>The <code>timestamp</code> 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. </p> <h3>Note</h3> <p>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 <code>savehistory()</code> in <code><a href="../../base/html/quit.html">.Last</a></code>. See the examples. </p> <h3>Examples</h3> <pre>## Not run: ## 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")) ## End(Not run)</pre> <hr /><div style="text-align: center;">[Package <em>utils</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>