dplyr error in select: unused argument

An unused argument error might appear with any function (for example, dplyr), and the primal cause is a misunderstanding. If the function appears with the same name in multiple active libraries, then make sure which of them you are using. If you are not using from the library what you think you are using, then it is no surprise that error appears.

 

For dplyr, this unused argument error happens because the MASS package also uses a function with the name “select”. You can detect that by writing the function in the console. When dplyr and MASS are loaded, then “select” is used with MASS.

One of the best solutions to this problem is using the name of the package (namespace) with the necessary function like this – dplyr::select.

Here is another way to handle this scenario. Detach the package if it is no longer needed. You can unload MASS or any other R package without restarting R or RStudio by using the detach function.

detach("package:MASS", unload = TRUE)

 

I hope that this post helps you deal with the dplyr unused argument error or in a similar situation with other packages.

Look at my top 10 dplyr tips and tricks, that will quickly improve your skills.

 




Posted

in

,

Comments

5 responses to “dplyr error in select: unused argument”

  1. Andy

    THank you very much for posting this, saved me so much time

  2. Johanna

    Thank you – super helpful.

  3. henrique

    thank you

  4. Ilan

    Thank you.
    It is very helpful

Leave a Reply

Your email address will not be published. Required fields are marked *