snippets avatar

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

snippets

Published: 02 Nov 2023 › Updated: 02 Nov 2023R: select() in both MAAS and dplyr causes problems

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

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.

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

Written by

A place for code snippets and everything else on programming that are useful.

Read more #programming posts


Best Posts From snippets

We have not curated any of snippets's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From snippets