coded.data {rsm} | R Documentation |
These functions facilitate the use of coded data in response-surface analysis.
coded.data(data, ..., formulas = list(...)) as.coded.data(data, ..., formulas = list(...)) decode.data(data) val2code(X, codings) code2val(X, codings) ## S3 method for class 'coded.data': print(x, ...) parse.coding(form)
data |
A data.frame |
... |
Formulas of the form x ~ (var - ctr) / scal , where
x is the name of the coded variable,
var is the name of the variable on its original scale,
ctr is the value to be coded as x = 0 , and
scal is the distance to 1 on the coded scale.
These formulas should be separated by commas.
|
formulas |
Provides an alternative way to provide the coding formulas. This is useful if you want to retrieve the codings from one dataset and use them for another. |
X |
A vector, matrix, or data.frame to be coded or decoded. |
codings |
a list of formulas (see form ) |
x |
Coded dataset to be printet. |
form |
A formula as described above for ... |
coded.data
and as.coded.data
return an object of class coded.data
,
which inherits from data.frame
. print.coded.data
is the print
method for this class; it simply prints the data.frame and then the formulas.
A named list
of the coding formulas is saved in
attr(, "codings")
.
Use coded.data
to convert a data.frame in which the variables
are on their original scales. The variables named in the formulas are
coded and replaced with their coded versions (and also renamed).
In contrast, as.coded.data
does not modify any of the data; it assumes the variables
are already coded, and the coding information is simply added.
decode.data
converts a dataset of class coded.data
and returns data.frame
containing the original variables.
code2val
converts coded values to the original scale using the codings provided,
and returns an object of the same class as X
.
val2code
converts the other direction. When using these functions, it is
essential that the names (or column names in the case of matrices) match those of the corresponding
coded or uncoded variables.
parse.coding
is mostly for internal use; it extracts and returns a list
with two vectors:
a character vector names
with the two variable names, and a numeric vector with the center and divisor.
Russell V. Lenth
library(rsm) CR = coded.data (ChemReact, x1~(Time-85)/5, x2~(Temp-175)/5) CR decode.data (CR) ### will be same as ChemReact code2val (c(x1=.5, x2=-1), codings = attr(CR, "codings"))