edit.data.frame {utils}R Documentation

Edit Data Frames and Matrices


Use data editor on data frame or matrix contents.


## S3 method for class 'data.frame':
edit(name, factor.mode = c("character", "numeric"),
     edit.row.names = any(row.names(name) != 1:nrow(name)), ...)

## S3 method for class 'matrix':
edit(name, edit.row.names = any(rownames(name) != 1:nrow(name)), ...)


name A data frame or matrix.
factor.mode How to handle factors (as integers or using character levels) in a data frame.
edit.row.names logical. Show the row names be displayed as a separate editable column?
... further arguments passed to or from other methods.


At present, this only works on simple data frames containing numeric, logical or character vectors and factors. Factors are represented in the spreadsheet as either numeric vectors (which is more suitable for data entry) or character vectors (better for browsing). After editing, vectors are padded with NA to have the same length and factor attributes are restored. The set of factor levels can not be changed by editing in numeric mode; invalid levels are changed to NA and a warning is issued. If new factor levels are introduced in character mode, they are added at the end of the list of levels in the order in which they encountered.

It is possible to use the data-editor's facilities to select the mode of columns to swap between numerical and factor columns in a data frame. Changing any column in a numerical matrix to character will cause the result to be coerced to a character matrix. Changing the mode of logical columns is not supported.

The columns are coerced on input to numeric unless logical, character or factor (which may well not be what you want), and character columns not protected by I() will be coerced to factor on return.


The edited data frame.


fix(dataframe) works for in-place editing by calling this function.

If the data editor is not available, a dump of the object is presented for editing using the default method of edit.

At present the data editor is limited to 65535 rows.


Peter Dalgaard

See Also

data.entry, edit


## Not run: 
edit(InsectSprays, factor.mode="numeric")
## End(Not run)

[Package utils version 2.1.0 Index]