I have some data such as:
data(iris)
I want to rename the columns such that Species
is the Y
variable and all other variables are the predictors.
What I have current doesn't give me the result I am looking for.
iris %>%
select(Species, everything()) %>% # move the Y variable to the "front"
rename(Y = 1) %>%
rename_at(vars(2:ncol(.)), ~ paste("X", seq(2:ncol(.)), sep = ""))
Expected output would be colnames:
Y, X1, X2, X3, X4, X5... XN