Learn R Programming

RSurvey (version 0.7-9)

EditData: Edit Data

Description

A GUI for viewing and editing table formatted data.

Usage

EditData(d, col.names = colnames(d), col.formats = NULL, read.only = FALSE,
         changelog = NULL, win.title = "Edit Data", parent = NULL)

Arguments

d
data.frame; the data used to populate the table.
col.names
character; a vector of column names.
col.formats
character; a vector of format conversion specification strings (optional), see sprintf and strftime.
read.only
logical; specifies whether the table is in read only mode.
changelog
data.frame; history of all data table edits (see Value).
win.title
character; a string to display as the title of the dialog box.
parent
tkwin; the GUI parent window.

Value

  • NULL is returned if no edits were made; otherwise, new values of d and changelog are returned as components in a list. The changelog data frame contains the following variables:
  • timestampPOSIXct; identifies when the edit event occurred.
  • recordcharacter; row name.
  • variablecharacter; column name.
  • oldcharacter; value before editing.
  • newcharacter; value after editing.

Details

Row titles are taken from the row names attribute of d. Pattern searches are performed using grep. Edits are reflected in the changelog.

Examples

Run this code
tcltk::tclRequire("Tktable", warn = TRUE)

n <- 1000L
V1 <- sample(c(1:9, NA), n, replace = TRUE)
V2 <- sample(LETTERS, n, replace = TRUE)
V3 <- as.POSIXct(rnorm(n, mean = 0, sd = 1e6), origin = "2010-01-01")
V4 <- sample(V1 * pi, n)
d <- data.frame(V1, V2, V3, V4)
col.names <- c("Integers", "Letters", "DateTime", "Numeric")
col.formats <- c("%d", "%s", "%m/%d/%Y %H:%M", "")
ans <- EditData(d, col.names, col.formats)
str(ans)

rownames(d) <- paste0(sample(LETTERS, n, replace = TRUE), 1:n)
EditData(d, read.only = TRUE)

colnames(d) <- NULL
rownames(d) <- NULL
EditData(d, read.only = TRUE)

Run the code above in your browser using DataLab