Rev 13351 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{dataentry}\title{Spreadsheet Interface for Entering Data}\usage{data.entry(\dots, Modes = NULL, Names = NULL)dataentry(data, modes)de(\dots, Modes = list(), Names = NULL)}\alias{data.entry}\alias{dataentry}\alias{de}\alias{de.ncols}\alias{de.restore}\alias{de.setup}\description{A spreadsheet-like editor for entering or editing data.}\arguments{\item{...}{A list of variables: currently these should be numeric orcharacter vectors or list containing such vectors.}\item{Modes}{The modes to be used for the variables.}\item{Names}{The names to be used for the variables.}\item{data}{A list of numeric and/or character vectors.}\item{modes}{A list of length up to that of \code{data} giving themodes of (some of) the variables. \code{list()} is allowed.}}\details{The data entry editor is only available on some platforms and GUIs.Where available it provides a means to visually edit a matrix ora collection of variables (including a data frame) as described in the``Notes'' section.\code{data.entry} has sideeffects, any changes made in the spreadsheet are reflected in thevariables. The functions \code{de}, \code{de.ncols}, \code{de.setup}and \code{de.restore} are designed to help achieve these side effects.If the user passes in a matrix, \code{X} say, then the matrix isbroken into columns before \code{dataentry} is called. Then on returnthe columns are collected and glued back together and the resultassigned to the variable \code{X}. If you don't want this behaviouruse dataentry directly.The primitive function is \code{dataentry}. It takes a list ofvectors of possibly different lengths and modes (the second argument)and opens a spreadsheet with these variables being the columns.The columns of the dataentry window are returned as vectors in alist when the spreadsheet is closed.\code{de.ncols} counts the number of columns which are supplied as argumentsto \code{data.entry}. It attempts to count columns in lists, matricesand vectors. \code{de.setup} sets things up so that on return thecolumns can be regrouped and reassigned to the correct name. Thisis handled by \code{de.restore}.}\value{\code{de} and \code{dataentry} return the edited value of theirarguments. \code{data.entry} invisibly returns a vector of variablenames but its main value is its side effect of assigning new versionof those variables in the user's workspace.}\note{The details of interface to the data grid may differ by platform andGUI. The following description applies to#ifdef unixthe X11-based implementation under Unix.#endif#ifdef windowsthe GraphApp-based implementation under Windows.#endifYou can navigate around the grid using the cursor keys or by clickingwith the (left) mouse button on any cell. The active cell ishighlighted by thickening the surrounding rectangle. Moving to theright or down will scroll the grid as needed: there is no constraintto the rows or columns currently in use.The are alternative ways to navigate using the keys. Return and(keypad) Enter and LineFeed all move down. Tab moves right andShift-Tab move left. Home moves to the top left.PageDown or Control-F moves down a page, and PageUp orControl-B up by a page. End will show the last used column and thelast few rows used (in any column).Using any other key starts an editing process on the currentlyselected cell: moving away from that cell enters the edited valuewhereas Esc cancels the edit and restores the previous value. Whenthe editing process starts the cell is cleared.#ifdef windowsThe cursor changes to an I-beam to indicate that the cell is in enter mode.#endifIn numerical columns(the default) only letters making up a valid number (including\code{-.eE}) are accepted, and entering an invalid edited value (suchas blank) enters \code{NA} in that cell. The last entered value canbe deleted using the BackSpace or Del(ete) key. Only a limitednumber of characters (currently 29) can be entered in a cell, and ifnecessary only the start or end of the string will be displayed, with theomissions indicated by \code{>} or \code{<}. (The start is shownexcept when editing.)#ifdef windowsDouble-clicking on a cell selects the cell and makes it into aneditable field (a cursor will appear at the end of the text and itwill change to the text highlight colour). The edited text isentered by selecting another cell, for example by hitting Return.There is no way to cancel the edits. The field will be expanded tothe right if necessary to accommodate existing long strings, so it ispreferable not to edit in the right-most displayed column. (Theeditable field is itself scrollable.)#endifEntering a value in a cell further down a column than the last usedcell extends the variable and fills the gap (if any) by \code{NA}s (notshown on screen).The column names can only be selected by clicking in them. This givesa popup menu to select the column type (currently Real (numeric) orCharacter) or to change the name. Changing the type converts thecurrent contents of the column (and converting from Character to Realmay generate \code{NA}s.)#ifdef unixIf changing the name is selected theheader cell becomes editable (and is cleared). As with all cells, thevalue is entered by moving away from the cell by clicking elsewhere orby any of the keys for moving down (only).#endif#ifdef windowsEnter the changes made in the popup window by clicking on its close box.#endifNew columns are created by entering values in them (and not by justassigning a new name). The mode of the column is auto-detected fromthe first value entered: if this is a valid number it gives a numericcolumn. Unused columns are ignored, soadding data in \code{var5} to a three-column grid adds one extravariable, not two.#ifdef windowsThere is a popup-menu accessed by right-clicking anywhere in the windowthat refers to the currently selected cell. This can copy the value toor paste from the clipboard, or paste in common values in that column.Copying and pasting can also be accessed by the usual keyboard shortcutsControl-C and Control-V.Columns can be resized by selecting and dragging a line (the cursorwill change) within limits: columns must be between 4 and 50 chars wide.The Autosize item on the popup menu will resize the currently selectedcolumn.#endif#ifdef unixThe \code{Copy} button copies the currently selected cell:\code{paste} copies the last copied value to the current cell, andright-clicking selects a cell \emph{and} copies in the value.Initially the value is blank, and attempts to paste a blank value willhave no effect.#endifControl-L will refresh the display, recalculating field widths to fitthe current entries.In the default mode the column widths are chosen to fit the contentsof each column, with a default of 10 characters for empty columns.you can specify fixed column widths by setting option\code{de.cellwidth} to the required fixed width (in characters).(set it to zero to return to variable widths). The displayedwidth of any field is limited to#ifdef unix600 pixels (and by the window width).#endif#ifdef windows50 characters (and by the window width).#endif}\seealso{\code{\link{vi}}, \code{\link{edit}}: \code{edit} uses\code{dataentry} to edit data frames.}\examples{# call data entry with variables x and y\dontrun{data.entry(x,y)}}\keyword{utilities}\keyword{file}