fary
September 14, 2021, 5:34am
1
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
fary
September 14, 2021, 5:59am
3
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?
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
system
Closed
October 5, 2021, 6:00am
5
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.