• Register
0 votes
653 views

Problem :

I want to select some columns from my data frame by the use of below code:

library(dplyr)

dv %>% select(LGA)

select(dv, LGA)

Both of them are failing with below error :

Unable to find an inherited method for function ‘select’ for signature ‘"data.frame"’

But my following code gives me desired output :

dplyr::select(dv, LGA)

Is there a confliction in packages?

My all libraries imported are as below:

library(jsonlite)

library(geojsonio)

library(dplyr)

library(ggmap)

library(geojson)

library(leaflet)

library(mapview)

library(RColorBrewer)

library(scales)

I' am very new to R, so need guidance in resolving the problems like this?

7.5k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

When you call select, R will searche through the "search path" and will matche the first function called select. And when you try to call dplyr::select then you are calling it directly from the namespace dplyr so the function will work as expected.

Below is an example using conflicted. We will try to load the raster and dplyr, here both of them have a select function.

library(dplyr)
library(raster)
library(conflicted)
d <- data.frame(a = 1:10, b = 1:10)

Now when we try to call select we will be prompted with the exact conflict:

> select(d, a)

Error: [conflicted] `select` found in 2 packages.
Either pick the one you want with `::` 
* raster::select
* dplyr::select
Or declare a preference with `conflict_prefer()`
* conflict_prefer("select", "raster")
* conflict_prefer("select", "dplyr")
38.6k points

Related questions

0 votes
1 answer 10 views
10 views
Problem: Unable to find an inherited method for function?
asked Jul 3 Nahil 122k points
0 votes
1 answer 2.1k views
2.1k views
Problem : When ever i use the predict glmnet function i get the below mentioned error error in cbind2(1, newx) %*% nbeta : not-yet-implemented method for <data.frame> %*% <dgcmatrix>
asked Nov 12, 2019 peterlaw 6.9k points
0 votes
1 answer 12 views
12 views
Problem: Cannot coerce class ""function"" to a data.frame.
asked Jun 30 Priscilla Gurpreet 71k points
1 vote
1 answer 31 views
31 views
Problem: I&rsquo;m new in data frame. I am doing a relatively simple piece of analysis which I have put into a function, on all the files in a particular folder. I was wondering whether anyone had any tips to help me automate the process on a number of different folders. Firstly, I was wondering whether there ... <- data.frame(A = c(4,2,6,8,1,0),B = (c(3,1,9,11,2,16))) Please help me to fix this.
asked Mar 10 Sabbir Hossain 14.6k points
0 votes
1 answer 46 views
46 views
Problem what is the function in r to get the # of observations in a data frame ?
asked Feb 9 charles mathews 5.5k points
0 votes
1 answer 45 views
45 views
Problem : I need answer to bellow issue don't know how to automatically pick scale for object of type data.frame. defaulting to continuous.
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 1.9k views
1.9k views
Problem : I need answer to bellow issue don't know how to automatically pick scale for object of type data.frame. defaulting to continuous.
asked Nov 7, 2019 peterlaw 6.9k points
0 votes
1 answer 2 views
2 views
Problem: Add multiple columns to data frame r.
asked 18 hours ago Priscilla Gurpreet 71k points
0 votes
1 answer 7 views
7 views
Problem: R create matrix from data frame columns.
asked Jul 22 akhi 121k points
0 votes
1 answer 7 views
7 views
Problem: R filter data frame multiple conditions.
asked Jul 21 Rada Gracelynn 100k points