Functions to preserve class design when editing a design and to use the view data button with class design objects

Share:

Description

Function showData allows to view data, function fix allows to edit data. For designs, it is only permitted to type in response data and other additional information like date or comments for experimental runs in R, such that all attributes of the design objects are updated accordingly. However, it is recommended to do such editing tasks outside of R, as R is not ideal for these.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
### generic function
fix(x, ...)
## Default S3 method:
fix(x, ...)
## S3 method for class 'design'
fix(x, ..., prompt=FALSE)
showData(dataframe,colname.bgcolor = "grey50", 
       rowname.bgcolor = "grey50", 
       body.bgcolor = "white", 
       colname.textcolor = "white", 
       rowname.textcolor = "white", 
       body.textcolor = "black",
       font = "Courier 12", 
       maxheight = 30, 
       maxwidth = 80, 
       title = NULL,
       rowname.bar = "left",
       colname.bar = "top",
       rownumbers = FALSE, 
       placement = "-20-40",
       suppress.X11.warnings = TRUE)
## Default S3 method:
showData(dataframe, 
       colname.bgcolor = "grey50", 
       rowname.bgcolor = "grey50", 
       body.bgcolor = "white", 
       colname.textcolor = "white", 
       rowname.textcolor = "white", 
       body.textcolor = "black",
       font = "Courier 12", 
       maxheight = 30, 
       maxwidth = 80, 
       title = NULL,
       rowname.bar = "left",
       colname.bar = "top",
       rownumbers = FALSE, 
       placement = "-20-40",
       suppress.X11.warnings = TRUE)
## S3 method for class 'design'
showData(dataframe,
       colname.bgcolor = "grey50", 
       rowname.bgcolor = "grey50", 
       body.bgcolor = "white", 
       colname.textcolor = "white", 
       rowname.textcolor = "white", 
       body.textcolor = "black",
       font = "Courier 12", 
       maxheight = 30, 
       maxwidth = 80, 
       title = NULL,
       rowname.bar = "left",
       colname.bar = "top",
       rownumbers = FALSE, 
       placement = "-20-40",
       suppress.X11.warnings = TRUE)

Arguments

x

an object of class design

...

further arguments to function fix from package utils

prompt

logical asking whether user is to be prompted for selecting which new numeric variable is a response; default: all new numeric variables are response variables

dataframe

data frame; if of S3 class design, the method for design is used, otherwise the default method

colname.bgcolor

as documented in relimp

rowname.bgcolor

as documented in relimp

body.bgcolor

as documented in relimp

colname.textcolor

as documented in relimp

rowname.textcolor

as documented in relimp

body.textcolor

as documented in relimp

font

as documented in relimp

maxheight

as documented in relimp

maxwidth

as documented in relimp

title

as documented in relimp

rowname.bar

as documented in relimp

colname.bar

as documented in relimp

rownumbers

as documented in relimp

placement

as documented in relimp

suppress.X11.warnings

as documented in relimp

Details

Function fix is made into an S3 generic. The default method preserves the functionality from package utils for all objects that are not of class design.

Function fix immediately commits all changes, overwriting the original object without further notice. This is also true for the method applicable to objects of class design, as long as the changes do not destroy the properties of the design. It is therefore wise to keep a copy of the original, until correctness of the changes is ascertained.

For design objects, changes are only committed, if no forbidden editing has been done: Changes in values of the experimental factors are not allowed and prevent storing edited information (only reported after the fact, user has no choice in the matter).
If the editing would destroy the structure of the design, e.g. because something was typed into an empty row of the data editor which leads to an extra row with missing values, a prompt allows to abort the changes; if changes are committed, the data frame is stored under its original name without any of its attributes (and can thus no longer be treated by any special tools for design objects).

The default method for showData is the function from package relimp, which is also used in R-Commander for viewing data sets. The method for class design objects is needed for successfully using the view button of design dataframes in R-commander. They are undesigned before viewing. However, it is preferrable to inspect a printout from function print.design which provides additional information. This can also be done in the R-Commander using the Design menu in package RcmdrPlugin.DoE (to be available soon).

Value

For the default function, refer to fix and the links therein.

The function for class design adds the numeric version (as.numeric) of all newly-entered variables to the desnum attribute of x and appends the names of all newly-entered response variables to the response.names element of the design.info attribute.

If numeric variables are to be entered that are no response variables, the function should be called with prompt=TRUE so that these are not taken to be response variables. Automatic default analyses (not yet available) would otherwise include analyses for these variables.

Warning

NOTE: Editing the data in R is only helpful for very small examples, especially when using the default editor under Windows.

NEVER do it to the one and only original data file. It does irrevocably replace it in many cases, even if you realize the mistakes you have made before leaving the editor window.

Author(s)

Ulrike Groemping

See Also

See also fix and the links therein

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
   ## Not run: 
   plan <- oa.design(L18)
   fix(plan)
    ## manually add some numeric data for the response
   response.names(plan)
   fix(plan, prompt=TRUE)
    ## manually add at least two numeric response columns
    ## select from menu which ones are to be responses
   response.names(plan)
   
## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.