2

Error message : could not find function "select"

After installing the package which contains the select function for R, this error isn't expected but still i am getting this error. I want to select a particular column of the dataset but the dollar sign operator is also not working.

Cristian E. Nuno
  • 2,822
  • 2
  • 19
  • 33
stuti sharma
  • 51
  • 1
  • 1
  • 4
  • 3
    Did you run `library(dplyr)` to actually load the package after you installed it? – MrFlick Feb 12 '18 at 20:13
  • Please consider reading [How to make a great R reproducible example?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Cristian E. Nuno Feb 13 '18 at 18:50
  • Sometimes a repoducable example is difficult to develop without extensive code, and sometimes it's even unnecessary. – cibr Jun 15 '20 at 15:51

3 Answers3

8

I think I've had this problem as well and I'm not sure what causes it. However, I can usually solve the problem by specifying the package before the command as in the code below.

dplyr::select()

Hope this helps.

THATguy
  • 292
  • 2
  • 11
3

@THATguy nailed it! That will solve your problems. The cause of this error is often due to multiple libraries with the same function. In this case specifically, the function "select" exists in the package 'dplyr' and 'MASS'. If you type in select in your code it's likely going to pull the MASS library, and if your intention is select only certain columns out of a data frame then, you want to the select from 'dplyr'. For example:

df <- read.csv("df.csv") %>% #bring in the data frame
      dplyr::select(-x, -y, -z) # remove the x, y, and z columns from the data frame

Or if you want to keep certain columns then drop the '-' in front of the variable.

0

There are various ways you can try to solve this problem.

  1. Restart the R session with ctrl + shift + F10
  2. You can use dplyr::select() if that's the select function you want
cmoshe
  • 329
  • 4
  • 7