I expect that trying to relocate a non-existing column with any_of would return the original dataframe. Even if the dataframe is empty. The function select seems to work more consistently with any_of.
My dplyr version is 1.0.7.
library(tidyverse) tibble(a=1:2) %>% relocate(any_of("b")) #> # A tibble: 2 × 1 #> a #> <int> #> 1 1 #> 2 2 tibble() %>% relocate(any_of("b")) #> Error: Can't subset columns that don't exist. #> x Location 1 doesn't exist. #> ℹ There are only 0 columns. tibble() %>% select(any_of("b")) #> # A tibble: 0 × 0
Created on 2022-01-28 by the reprex package (v2.0.1)