transform {base} | R Documentation |
Transform an Object, for Example a Data Frame
Description
transform
is a generic function, which—at leastcurrently—only does anything useful withdata frames.transform.default
converts its first argument toa data frame if possible and callstransform.data.frame
.
Usage
transform(`_data`, ...)
Arguments
_data | The object to be transformed |
... | Further arguments of the form |
Details
The...
arguments totransform.data.frame
are taggedvector expressions, which are evaluated in the data frame_data
. The tags are matched againstnames(_data)
, and forthose that match, the value replace the corresponding variable in_data
, and the others are appended to_data
.
Value
The modified value of_data
.
Warning
This is a convenience function intended for use interactively. Forprogramming it is better to use the standard subsetting arithmetic functions,and in particular the non-standard evaluation ofargumenttransform
can have unanticipated consequences.
Note
If some of the values are not vectors of the appropriate length,you deserve whatever you get!
Author(s)
Peter Dalgaard
See Also
within
for a more flexible approach,subset
,list
,data.frame
Examples
transform(airquality, Ozone = -Ozone)transform(airquality, new = -Ozone, Temp = (Temp-32)/1.8)attach(airquality)transform(Ozone, logOzone = log(Ozone)) # marginally interesting ...detach(airquality)