transform

0th

Percentile

Transform an Object, for Example a Data Frame

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.

Keywords
manip
Usage
transform(`_data`, …)
Arguments
_data

The object to be transformed

Further arguments of the form tag=value

Details

The 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.

Value

The modified value of _data.

Note

If some of the values are not vectors of the appropriate length, you deserve whatever you get!

Warning

This is a convenience function intended for use interactively. For programming it is better to use the standard subsetting arithmetic functions, and in particular the non-standard evaluation of argument transform can have unanticipated consequences.

See Also

within for a more flexible approach, subset, list, data.frame

Aliases
  • transform
  • transform.default
  • transform.data.frame
Examples
library(base) # NOT RUN { transform(airquality, Ozone = -Ozone) transform(airquality, new = -Ozone, Temp = (Temp-32)/1.8) attach(airquality) transform(Ozone, logOzone = log(Ozone)) # marginally interesting ... detach(airquality) # }
Documentation reproduced from package base, version 3.5.1, License: Part of R 3.5.1

Community examples

yang2819281@gmail.com at Oct 1, 2018 base v3.5.1

mtcars <- transform(mtcars, mpg=mpg^2)