Since this is mainly just using x[i] it should be using dplyr_col_select() internally, which patches the [ method of base R data frames and data.table objects to retain attributes
library(dplyr)
df <- vctrs::data_frame(x = 1, y = 2)
attr(df, "foo") <- "bar"
out <- relocate(df, y, .before = x)
attr(out, "foo")
#> NULL
Since mutate() also uses relocate(), that should fix the same kind of issue that comes from mutate() + .before
library(dplyr)
df <- vctrs::data_frame(x = 1, y = 2)
attr(df, "foo") <- "bar"
out <- mutate(df, z = 3, .before = x)
attr(out, "foo")
#> NULL
Since this is mainly just using
x[i]it should be usingdplyr_col_select()internally, which patches the[method of base R data frames and data.table objects to retain attributesSince
mutate()also usesrelocate(), that should fix the same kind of issue that comes frommutate()+.before