
Last chance! 50% off unlimited learning
Sale ends in
transform
is a generic function, which---at least
currently---only does anything useful with
data frames. transform.default
converts its first argument to
a data frame if possible and calls transform.data.frame
.
transform(`_data`, ...)
tag=value
transform
can have unanticipated consequences. ...
arguments to transform.data.frame
are tagged
vector expressions, which are evaluated in the data frame
_data
. The tags are matched against names(_data)
, and for
those that match, the value replace the corresponding variable in
_data
, and the others are appended to _data
.
within
for a more flexible approach,
subset
,
list
,
data.frame
transform(airquality, Ozone = -Ozone)
transform(airquality, new = -Ozone, Temp = (Temp-32)/1.8)
attach(airquality)
transform(Ozone, logOzone = log(Ozone)) # marginally interesting ...
detach(airquality)
Run the code above in your browser using DataLab