The R Project SVN R

Rev

Rev 85953 | Details | Compare with Previous | Last modification | View Log | RSS feed

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