I want to build my function to change the column name.
x1 = c(1:5)
x2 = c(6:10)
x = data.frame(
X1 = x1,
X2 = x2
)
myFunction = function(x) {
x <- rename(x, "newX1" = "X1")
x <- rename(x, "newX2" = "X2")
newX <- x
return(newX)
}
print(myFunction(x))
output is below:
newX1 newX2
1 1 6
2 2 7
3 3 8
4 4 9
5 5 10
I can see the result that I intended, but the output does not store as data in my memory. I want to do the next process using the output (data) of the function.
Thank you.