if (FALSE) {
data(iris)
iris %>%
move_columns(Sepal.Width, .after = "Species") %>%
head()
iris %>%
move_columns(Sepal.Width, .before = Sepal.Length) %>%
head()
iris %>%
move_columns(Species, .before = 1) %>%
head()
iris %>%
move_columns("Species", "Petal.Length", .after = 1) %>%
head()
library(dplyr)
iris %>%
move_columns(contains("Width"), .after = "Species") %>%
head()}
# using quasi-quotation
target <- "Petal.Width"
# does not work, column is moved to the end
iris %>%
move_columns(Sepal.Width, .after = target) %>%
head()
# using !! works
iris %>%
move_columns(Sepal.Width, .after = !!target) %>%
head()
Run the code above in your browser using DataLab