Reputation: 51
Error message : could not find function "select"
After installing the package dplyr 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.
Upvotes: 2
Views: 26066
Reputation: 369
There are various ways you can try to solve this problem.
ctrl + shift + F10
dplyr::select()
if that's the select function you wantUpvotes: 0
Reputation: 31
@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.
Upvotes: 3
Reputation: 312
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.
Upvotes: 9