add.response | R Documentation |
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 design.info 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, ...)
design |
a character string that gives the name of a class |
response |
EITHER a numeric vector, numeric matrix or data frame with at least one numeric variable (the treatment of these is explained in the details section) OR 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 |
rdapath |
a character string indicating the path to a stored rda file that contains the design |
replace |
logical: TRUE implies that existing variables are overwritten in |
InDec |
decimal separator in the external csv file; defaults to the
|
tol |
tolerance for comparing numerical values; |
... |
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 design.info
attribute
or the block.name
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 export.design
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 design.info
attribute is added or modified
Ulrike Groemping
See also export.design
plan <- fac.design(nlevels=c(2,3,2,4))
result <- rnorm(2*3*2*4)
add.response(plan,response=result)
## direct use of rnorm() is also possible, but looks better with 48
add.response(plan,response=rnorm(48))
## Not run:
export.design(path="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)
add.response(design="plan",response="c:/projectA/experiments/plan.csv",
rdapath="c:/projectA/experiments/plan.rda")
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.