R: select() in both MAAS and dplyr causes problems

in R Programminglast year

For those in tidyverse, dplyr has this handy function called select() that picks out just the variables based on the the column we need from a data frame.

Unfortunately, there’s also this other cool package called MASS which also has a function called select().

When I load both of these packages into my R session and just type select(), my code breaks because I am not sure R uses what I need.

This is where the magic of :: comes in. It allows us to specify which package's function to call.

For example, MASS::select() calls the select() from MASS, while dplyr::select() uses the select from dplyr.

In rare cases would there be duplicate function names in different packages, and if we encounter such cases, specifying the package is the way to solve it.