R: Invoke a Text Editor (original) (raw)
edit {utils} | R Documentation |
---|
Description
Invoke a text editor on an R object.
Usage
edit(name, ...)
## Default S3 method:
edit(name = NULL, file = "", title = NULL,
editor = getOption("editor"), ...)
vi(name = NULL, file = "")
emacs(name = NULL, file = "")
pico(name = NULL, file = "")
xemacs(name = NULL, file = "")
xedit(name = NULL, file = "")
Arguments
name | a named object that you want to edit. For the default method, if name is missing then the file specified byfile is opened for editing. |
---|---|
file | a string naming the file to write the edited version to. |
title | a display name for the object being edited. |
editor | usually a character string naming (or giving the path to) the text editor you want to use. On Unix the default is set from the environment variables EDITOR or VISUAL if either is set, otherwise vi is used. On Windows it defaults to"internal", the script editor. On the macOS GUI the argument is ignored and the document editor is always used. editor can also be an R function, in which case it is called with the arguments name, file, and title. Note that such a function will need to independently implement all desired functionality. |
... | further arguments to be passed to or from methods. |
Details
edit
invokes the text editor specified by editor
with the object name
to be edited. It is a generic function, currently with a default method and one for data frames and matrices.
data.entry
can be used to edit data, and is used by edit
to edit matrices and data frames on systems for whichdata.entry
is available.
It is important to realize that edit
does not change the object called name
. Instead, a copy of name is made and it is that copy which is changed. Should you want the changes to apply to the object name
you must assign the result of edit
toname
. (Try [fix](../../utils/help/fix.html)
if you want to make permanent changes to an object.)
In the form edit(name)
,edit
deparses name
into a temporary file and invokes the editor editor
on this file. Quitting from the editor causesfile
to be parsed and that value returned. Should an error occur in parsing, possibly due to incorrect syntax, no value is returned. Calling edit()
, with no arguments, will result in the temporary file being reopened for further editing.
Note that deparsing is not perfect, and the object recreated after editing can differ in subtle ways from that deparsed: see[dput](../../base/html/dput.html)
and [.deparseOpts](../../base/html/deparseOpts.html)
. (The deparse options used are the same as the defaults for dump
.) Editing a function will preserve its environment. See[edit.data.frame](../../utils/help/edit.data.frame.html)
for further changes that can occur when editing a data frame or matrix.
Currently only the internal editor in Windows makes use of thetitle
option; it displays the given name in the window header.
Note
The functions vi
, emacs
, pico
, xemacs
,xedit
rely on the corresponding editor being available and being on the path. This is system-dependent.
See Also
[edit.data.frame](../../utils/help/edit.data.frame.html)
,[data.entry](../../utils/help/data.entry.html)
,[fix](../../utils/help/fix.html)
.
Examples
## Not run:
# use xedit on the function mean and assign the changes
mean <- edit(mean, editor = "xedit")
# use vi on mean and write the result to file mean.out
vi(mean, file = "mean.out")
## End(Not run)
[Package _utils_ version 4.6.0 Index]