| powerTransform | R Documentation | 
data.frame data.Perform a combination of a linear and a power transformation on a variable 
whose name is given as a character string in var.name. The transformed 
variable is stored in the data.frame data. The name of the transformed 
variable is made by prepending to the original var.name a combination of 
(i) .offset, if offset is nonzero, 
(ii) neg., if scale is -1, or scaled., if abs(scale) 
is other than one, and (iii) either log., sqrt., recip. or 
power., if power is other than one. 
No action is taken if there is no transformation (i.e. offset = 0, 
scale = 1 and power = 1). Also, the titles list is 
extended to include a component with a generated title for the 
transformed variable with text indicating the transformation prepended 
to the title for the var.name obtained from the 
titles list.  For nonzero offset, ‘Offset ’ is prepended, 
For scaled not equal to one, the possible prepends are ‘Negative of ’  
and ‘Scaled ’. The possible prepended texts for power not equal to one 
are ‘Logarithm of’, ‘Square root of ’, ‘Reciprocal of ’ and ‘Power nnnn of ’, 
where nnn is the power used.
powerTransform(var.name, power = 1, offset = 0, scale = 1, titles = NULL, data)| var.name | A  | 
| power | A number specifying the power to be used in the transformation. 
If equal to 1, the default, no power transformation is applied. 
Otherwise, the variable is raised to the specified  | 
| offset | A number to be added to each value of the variable, after any scaling and before applying any power transformation. | 
| scale | A number to multiply each value of the variable, before adding any offset and applying any power transformation. | 
| titles | A  | 
| data | A  | 
A list with a component named data that is the data.frame containing the 
transformed variable, a component named tvar.name that is a character string 
that is the name of the transformed variable in data, and a component named 
titles that extends the list supplied in the titles argument to 
include a generated title for the transformed title, the name of the new component being 
tvar.name.
Chris Brien
angular, angular.mod.
## set up a factor with labels
x.dat <- data.frame(y = c(14, 42, 120, 150))
 
## transform y to logarithms
trans <- powerTransform("y", power = 0, titles=list(y = "Length (cm)"), data = x.dat)
x.dat <- trans$data
tvar.name <- trans$tvar.name
## transform y to logarithms after multiplying by -1 and adding 1.
z.dat <- data.frame( y = c(-5.25, -4.29, -1.22, 0.05))
trans <- powerTransform("y", power = 0, scale = -1, offset = 1 ,
                        titles=list(y = "Potential"), data = z.dat)
z.dat <- trans$data
tvar.name <- trans$tvar.name
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.