1
library(dplyr)
df %>%
  select(starts_with("a"))

Throws an error:

Error in select(., starts_with("special_int")) : 
  unused argument (starts_with("special_int"))

The error resolves when I specify dplyr in front of the function, as in ```dplyr::select()``

Does anyone know why this happens and how to prevent it?

Kelsey
  • 199
  • 6
  • 2
    Does this answer your question? [Error with select function from dplyr](https://stackoverflow.com/questions/46325145/error-with-select-function-from-dplyr) – slamballais Jun 08 '21 at 16:48
  • What does `environment(select)` return? That might give you a clue where the conflicting `select` function is coming from. – MrFlick Jun 08 '21 at 17:03

1 Answers1

2

It is because select function occurs in different packages and this could mask the dplyr::select if those packages are loaded after dplyr. When we specify the ::, then it gets the correct function. So either,

df %>%
   dplyr::select(starts_with("a"))

Or create a new name and call it

dpselect <- dplyr::select
df %>%
   dpselect(starts_with("a"))

In base R, we can find the functions that have some conflicts

conflicts()
akrun
  • 874,273
  • 37
  • 540
  • 662