| 42333 |
ripley |
1 |
% File src/library/utils/man/dataentry.Rd
|
|
|
2 |
% Part of the R package, http://www.R-project.org
|
| 59039 |
ripley |
3 |
% Copyright 1995-2009 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 27442 |
ripley |
6 |
\name{dataentry}
|
|
|
7 |
\title{Spreadsheet Interface for Entering Data}
|
|
|
8 |
\usage{
|
|
|
9 |
data.entry(\dots, Modes = NULL, Names = NULL)
|
|
|
10 |
dataentry(data, modes)
|
|
|
11 |
de(\dots, Modes = list(), Names = NULL)
|
|
|
12 |
}
|
|
|
13 |
\alias{data.entry}
|
| 56186 |
murdoch |
14 |
\alias{dataentry}
|
| 27442 |
ripley |
15 |
\alias{de}
|
|
|
16 |
\alias{de.ncols}
|
|
|
17 |
\alias{de.restore}
|
|
|
18 |
\alias{de.setup}
|
|
|
19 |
\description{
|
|
|
20 |
A spreadsheet-like editor for entering or editing data.
|
|
|
21 |
}
|
|
|
22 |
\arguments{
|
|
|
23 |
\item{\dots}{A list of variables: currently these should be numeric or
|
|
|
24 |
character vectors or list containing such vectors.}
|
|
|
25 |
\item{Modes}{The modes to be used for the variables.}
|
|
|
26 |
\item{Names}{The names to be used for the variables.}
|
|
|
27 |
\item{data}{A list of numeric and/or character vectors.}
|
|
|
28 |
\item{modes}{A list of length up to that of \code{data} giving the
|
|
|
29 |
modes of (some of) the variables. \code{list()} is allowed.}
|
|
|
30 |
}
|
|
|
31 |
\details{
|
|
|
32 |
The data entry editor is only available on some platforms and GUIs.
|
|
|
33 |
Where available it provides a means to visually edit a matrix or
|
|
|
34 |
a collection of variables (including a data frame) as described in the
|
| 42961 |
ripley |
35 |
Notes section.
|
| 61433 |
ripley |
36 |
|
| 47874 |
ripley |
37 |
\code{data.entry} has side effects, any changes made in the
|
|
|
38 |
spreadsheet are reflected in the variables. The functions \code{de},
|
|
|
39 |
\code{de.ncols}, \code{de.setup} and \code{de.restore} are designed to
|
|
|
40 |
help achieve these side effects. If the user passes in a matrix,
|
|
|
41 |
\code{X} say, then the matrix is broken into columns before
|
|
|
42 |
\code{dataentry} is called. Then on return the columns are collected
|
|
|
43 |
and glued back together and the result assigned to the variable
|
|
|
44 |
\code{X}. If you don't want this behaviour use dataentry directly.
|
| 27442 |
ripley |
45 |
|
|
|
46 |
The primitive function is \code{dataentry}. It takes a list of
|
|
|
47 |
vectors of possibly different lengths and modes (the second argument)
|
|
|
48 |
and opens a spreadsheet with these variables being the columns.
|
|
|
49 |
The columns of the dataentry window are returned as vectors in a
|
|
|
50 |
list when the spreadsheet is closed.
|
|
|
51 |
|
|
|
52 |
\code{de.ncols} counts the number of columns which are supplied as arguments
|
|
|
53 |
to \code{data.entry}. It attempts to count columns in lists, matrices
|
|
|
54 |
and vectors. \code{de.setup} sets things up so that on return the
|
|
|
55 |
columns can be regrouped and reassigned to the correct name. This
|
|
|
56 |
is handled by \code{de.restore}.
|
|
|
57 |
}
|
|
|
58 |
\value{
|
|
|
59 |
\code{de} and \code{dataentry} return the edited value of their
|
|
|
60 |
arguments. \code{data.entry} invisibly returns a vector of variable
|
|
|
61 |
names but its main value is its side effect of assigning new version
|
|
|
62 |
of those variables in the user's workspace.
|
|
|
63 |
}
|
|
|
64 |
\note{
|
|
|
65 |
The details of interface to the data grid may differ by platform and
|
|
|
66 |
GUI. The following description applies to
|
|
|
67 |
#ifdef unix
|
|
|
68 |
the X11-based implementation under Unix.
|
|
|
69 |
#endif
|
|
|
70 |
#ifdef windows
|
|
|
71 |
the GraphApp-based implementation under Windows.
|
|
|
72 |
#endif
|
|
|
73 |
|
|
|
74 |
You can navigate around the grid using the cursor keys or by clicking
|
|
|
75 |
with the (left) mouse button on any cell. The active cell is
|
|
|
76 |
highlighted by thickening the surrounding rectangle. Moving to the
|
|
|
77 |
right or down will scroll the grid as needed: there is no constraint
|
|
|
78 |
to the rows or columns currently in use.
|
|
|
79 |
|
| 27625 |
ripley |
80 |
There are alternative ways to navigate using the keys. Return and
|
| 27442 |
ripley |
81 |
(keypad) Enter and LineFeed all move down. Tab moves right and
|
|
|
82 |
Shift-Tab move left. Home moves to the top left.
|
|
|
83 |
|
|
|
84 |
PageDown or Control-F moves down a page, and PageUp or
|
|
|
85 |
Control-B up by a page. End will show the last used column and the
|
|
|
86 |
last few rows used (in any column).
|
|
|
87 |
|
|
|
88 |
Using any other key starts an editing process on the currently
|
|
|
89 |
selected cell: moving away from that cell enters the edited value
|
|
|
90 |
whereas Esc cancels the edit and restores the previous value. When
|
|
|
91 |
the editing process starts the cell is cleared.
|
|
|
92 |
#ifdef windows
|
|
|
93 |
The cursor changes to an I-beam to indicate that the cell is in enter mode.
|
|
|
94 |
#endif
|
|
|
95 |
In numerical columns
|
|
|
96 |
(the default) only letters making up a valid number (including
|
|
|
97 |
\code{-.eE}) are accepted, and entering an invalid edited value (such
|
|
|
98 |
as blank) enters \code{NA} in that cell. The last entered value can
|
|
|
99 |
be deleted using the BackSpace or Del(ete) key. Only a limited
|
|
|
100 |
number of characters (currently 29) can be entered in a cell, and if
|
|
|
101 |
necessary only the start or end of the string will be displayed, with the
|
|
|
102 |
omissions indicated by \code{>} or \code{<}. (The start is shown
|
|
|
103 |
except when editing.)
|
|
|
104 |
|
|
|
105 |
#ifdef windows
|
|
|
106 |
Double-clicking on a cell selects the cell and makes it into an
|
|
|
107 |
editable field (a cursor will appear at the end of the text and it
|
|
|
108 |
will change to the text highlight colour). The edited text is
|
|
|
109 |
entered by selecting another cell, for example by hitting Return.
|
|
|
110 |
There is no way to cancel the edits. The field will be expanded to
|
|
|
111 |
the right if necessary to accommodate existing long strings, so it is
|
|
|
112 |
preferable not to edit in the right-most displayed column. (The
|
|
|
113 |
editable field is itself scrollable.)
|
|
|
114 |
#endif
|
|
|
115 |
|
|
|
116 |
Entering a value in a cell further down a column than the last used
|
|
|
117 |
cell extends the variable and fills the gap (if any) by \code{NA}s (not
|
|
|
118 |
shown on screen).
|
|
|
119 |
|
|
|
120 |
The column names can only be selected by clicking in them. This gives
|
|
|
121 |
a popup menu to select the column type (currently Real (numeric) or
|
|
|
122 |
Character) or to change the name. Changing the type converts the
|
|
|
123 |
current contents of the column (and converting from Character to Real
|
|
|
124 |
may generate \code{NA}s.)
|
|
|
125 |
#ifdef unix
|
|
|
126 |
If changing the name is selected the
|
|
|
127 |
header cell becomes editable (and is cleared). As with all cells, the
|
|
|
128 |
value is entered by moving away from the cell by clicking elsewhere or
|
|
|
129 |
by any of the keys for moving down (only).
|
|
|
130 |
#endif
|
|
|
131 |
#ifdef windows
|
|
|
132 |
Enter the changes made in the popup window by clicking on its close box.
|
|
|
133 |
#endif
|
|
|
134 |
|
|
|
135 |
New columns are created by entering values in them (and not by just
|
|
|
136 |
assigning a new name). The mode of the column is auto-detected from
|
|
|
137 |
the first value entered: if this is a valid number it gives a numeric
|
|
|
138 |
column. Unused columns are ignored, so
|
|
|
139 |
adding data in \code{var5} to a three-column grid adds one extra
|
|
|
140 |
variable, not two.
|
|
|
141 |
|
|
|
142 |
#ifdef windows
|
|
|
143 |
There is a popup-menu accessed by right-clicking anywhere in the window
|
|
|
144 |
that refers to the currently selected cell. This can copy the value to
|
|
|
145 |
or paste from the clipboard, or paste in common values in that column.
|
|
|
146 |
Copying and pasting can also be accessed by the usual keyboard shortcuts
|
|
|
147 |
Control-C and Control-V.
|
|
|
148 |
|
|
|
149 |
Columns can be resized by selecting and dragging a line (the cursor
|
|
|
150 |
will change) within limits: columns must be between 4 and 50 chars wide.
|
|
|
151 |
The Autosize item on the popup menu will resize the currently selected
|
|
|
152 |
column.
|
|
|
153 |
#endif
|
|
|
154 |
#ifdef unix
|
|
|
155 |
The \code{Copy} button copies the currently selected cell:
|
|
|
156 |
\code{paste} copies the last copied value to the current cell, and
|
|
|
157 |
right-clicking selects a cell \emph{and} copies in the value.
|
|
|
158 |
Initially the value is blank, and attempts to paste a blank value will
|
|
|
159 |
have no effect.
|
|
|
160 |
#endif
|
| 61433 |
ripley |
161 |
|
| 27442 |
ripley |
162 |
Control-L will refresh the display, recalculating field widths to fit
|
|
|
163 |
the current entries.
|
|
|
164 |
|
|
|
165 |
In the default mode the column widths are chosen to fit the contents
|
|
|
166 |
of each column, with a default of 10 characters for empty columns.
|
|
|
167 |
you can specify fixed column widths by setting option
|
|
|
168 |
\code{de.cellwidth} to the required fixed width (in characters).
|
|
|
169 |
(set it to zero to return to variable widths). The displayed
|
|
|
170 |
width of any field is limited to
|
|
|
171 |
#ifdef unix
|
|
|
172 |
600 pixels (and by the window width).
|
|
|
173 |
#endif
|
|
|
174 |
#ifdef windows
|
|
|
175 |
50 characters (and by the window width).
|
| 61433 |
ripley |
176 |
|
| 48873 |
murdoch |
177 |
The initial size of the data editor window is taken from the default
|
| 47874 |
ripley |
178 |
dimensions of a pager (see \code{\link{Rconsole}}), but adjusted
|
|
|
179 |
downwards to show a whole number of rows and columns.
|
| 27442 |
ripley |
180 |
#endif
|
|
|
181 |
}
|
| 36044 |
ripley |
182 |
#ifdef unix
|
|
|
183 |
\section{Resources}{
|
|
|
184 |
The data entry window responds to X resources of class
|
|
|
185 |
\code{R_dataentry}. Resources \code{foreground}, \code{background} and
|
|
|
186 |
\code{geometry} are utilized.
|
|
|
187 |
}
|
|
|
188 |
#endif
|
| 27442 |
ripley |
189 |
\seealso{
|
|
|
190 |
\code{\link{vi}}, \code{\link{edit}}: \code{edit} uses
|
|
|
191 |
\code{dataentry} to edit data frames.
|
|
|
192 |
}
|
|
|
193 |
\examples{
|
|
|
194 |
# call data entry with variables x and y
|
| 61168 |
ripley |
195 |
\dontrun{data.entry(x, y)}
|
| 27442 |
ripley |
196 |
}
|
|
|
197 |
\keyword{utilities}
|
|
|
198 |
\keyword{file}
|