I have a DF
with two columns and I would like to offset my second column with mutate
. The problem is that column names are variable and I don't know how to use mutate
in this case.
I tried to follow the example of this question, but I couldn't reach my goal.
Example:
df <- data.frame(x = 1:150, y = 1:150)
df %>%
mutate(x = lag(x, 1))
My variable x
changes its name with another DF's
.