Error: Selections can't have missing values.

hello everybody
I am new to r and trying to cleaning my data.
i was working on my dataset last night and now when I want to clean the rest of them by running this line of code (df<-dff %>% select(any_of(names))) I get this error.
Error: Selections can't have missing values.
Run rlang::last_error() to see where the error occurred.

i was working last night and now....

setwd("C:/Users........data/request")
## baseline
N<-read_excel("Baseline_BC.xlsx", "Nutrition", skip = 2, n_max=2000)
variables<- rbind(N)
Baseline_BC<- variables %>% filter(Selection!="X")
# cleaning Baseline/ General ------------------------------------------------------
setwd("C:/Users/......../raw/baseline")
bb = list.files(path = "./raw/baseline",pattern="*.xlsx")
dff <-read_excel('C:/Users/.......Nutrition_FoodAllergies.xlsx')
##
names<-variables$`Variable name`
df<-dff %>% select(any_of(names))
description<-as.data.frame(names(df))
description<-left_join(description, variables[,], by=c("names(df)"="Variable name"))

Is this what you are after?

library(dplyr)

variables <- c("cyl", "hp", "wt")

mtcars %>% 
  select(variables)


                  cyl  hp    wt
Mazda RX4           6 110 2.620
Mazda RX4 Wag       6 110 2.875
Datsun 710          4  93 2.320
Hornet 4 Drive      6 110 3.215
Hornet Sportabout   8 175 3.440
Valiant             6 105 3.460

I am new to r and I apologize in advance if my question is stupid.
i want to know why i get this error. because it worked well and now i have this problem. i did not change anything.

Can you provide a reproducible example?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.