add.response: Function to add response values to an experimental design

View source: R/add.response.R

add.responseR Documentation

Function to add response values to an experimental design


This function allows to add numeric response variables to an experimental plan of class design. The responses are added both to the data frame and to its desnum attribute; the response.names element of the attribute is updated - the function is still experimental.


add.response(design, response, rdapath=NULL, replace = FALSE, 
    InDec=options("OutDec")[[1]], tol = .Machine$double.eps ^ 0.5, ...)



a character string that gives the name of a class design object, to which responses are to be added



a numeric vector, numeric matrix or data frame with at least one numeric variable (the treatment of these is explained in the details section)


a character string indicating a csv file that contains the typed-in response values; after reading the csv file with the csv version indicated in the InDec argument, numeric variables from response will be added to the design as responses


a character string indicating the path to a stored rda file that contains the design


logical: TRUE implies that existing variables are overwritten in design; cf. also the details section


decimal separator in the external csv file; defaults to the OutDec option (viewable under options("OutDec"), and also governs whether the csv-file is read with read.csv or with read.csv: separator semicolon goes with decimal comma and triggers use of read.csv2, separator comma goes with decimal point and trigggers use of read.csv. )


tolerance for comparing numerical values;
useful for designs with numeric factors and for partial replacement of response values; the value is used in comparisons of design and response via all.equal; errors from peculiar rounding behavior of spreadsheet programs can be prevented by allowing a larger tol


further arguments; currently not used


If response is a data frame or a matrix, responses are assumed to be all the numeric variables that are neither factor names or block names in design (i.e. names of the factor.names element of the attribute or the element of that same attribute) nor column names of the run.order attribute, nor name or Name.

If design already contains columns for the response(s), NA entries of these are overwritten, if all non-NA entries coincide between design and response.

The idea behind this function is as follows: After using for storing an R work space with the design object and either a csv or html file externally, Excel or some other external software is used to type in experimental information. The thus-obtained data sheet is saved as a csv-file and imported into R again (name provided in argument response, and the design object with all attached information is linked to the typed in response values using function add.response.

Alternatively, it is possible to simply type in experimental results in R, both using the R commander plugin (RcmdrPlugin.DoE) or simply function fix. Copy-pasting into R from Excel is per default NOT possible, which has been the reason for programming this routine.


The value is a modified version of the argument object design, which remains an object of class design with the following modifications:

  • Response columns are added to the data frame

  • the same response columns are added to the desnum attribute

  • the response.names element of the attribute is added or modified


Ulrike Groemping

See Also

See also


       plan <-,3,2,4))
       result <- rnorm(2*3*2*4)
       ## direct use of rnorm() is also possible, but looks better with 48 
   ## Not run:  "c:/projectA/experiments",plan)
       ## open exported file c:/projectA/experiments/plan.html
       ##        with Excel
       ## carry out the experiment, input data in Excel or elsewhere
       ##        store as csv file with the same name (or a different one, just use 
       ##        the correct storage name later in R), after deleting 
       ##        the legend portion to the right of the data area
       ##        (alternatively, input data by typing them in in R (function fix or R-commander)
       ## plan is the name of the design in the workspace stored in rdapath
       ## assuming only responses were typed in
       ## should work on your computer regardless of system, 
       ##         if you adapt the path names accordingly
## End(Not run)

DoE.base documentation built on Nov. 15, 2023, 1:06 a.m.