transform() function in R Language is used to modify data. It converts the first argument to the data frame.
This function is used to transform/modify the data frame in a quick and easy way.
data: Data Frame to be modified
value: new modified value of data
Example 1: Use transform() on variables
x1= 11, 12, 13, 14. x2 = 5, 6, 7, 8.
Here in the above code, we have a data framework and we transform it by adding 10(x1 = x1 + 10) to each of the values.
The values of x2 will not get changed as we do not apply any transformation to it.
Example 2: Add new variables to data
X1= 11, 12, 13, 14. X2 = 5, 6, 7, 8. X3 = 1, 3, 3, 4.
Here in the above code, we are adding a new variable x3 to the previous data.