Question about dplyr

Hello everyone. Yesterday, in class, oru professor provided us with the following code

counties <- read.table("counties.csv" ,header = T,sep = ";") 

selec6<-counties %>%
  select(contains("uction"), starts_with("income"), ends_with("work"), last_col())
selec7<-counties %>% 

I was wondering if there is a reason to select a part of the dataframe using matches instead of constraints. Can someone please solve this question?

Best regards.

Contains is for literal string, matches also for a regular expression, for example select(matches("name\\d+")) can match column named name1, name2 etc…

1 Like

This topic was automatically closed 7 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.