• Register
0 votes

Problem :

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


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:










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

6 5 3
7,540 points

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.

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")
9 7 4
38,600 points

Related questions

0 votes
1 answer 1.2K 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 888 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
2 answers 775 views
Problem : How to solve the below error, I will first show an example of the data file. My Data file: col1  col2    col3 1     2       3 1     2       3 5     6       7 My R code: read.table("mydemo.txt", header = TRUE, sep = "\t", row.names = "a") My Output ... In read.table(file = file, header = header, sep = sep, quote = quote,  : incomplete final line found by readTableHeader on '../mydemo.txt'
asked Jan 17 jwilliam 3.9k points
0 votes
1 answer 1.6K views
Problem : I have been facing below error message and traceback: Error in FUN(X[[i]], ...) : only defined on the data frame with all numeric variables 5 stop("only defined on the data frame with all numeric variables") 4 FUN(X[[i]], ...) 3 lapply(args, ... .numeric(data[good,]) But now I get the different error message back as below : "Error: (list) object cannot be coerced to type 'double'"
asked Dec 16, 2019 alecxe 7.5k points
0 votes
2 answers 1.1K views
Problem : I am facing below error and I am unable to understand the meaning of the error. All my variable names are correct and there are no typing errors. Does anybody faced this issue before any solution on it? My erroneous code : datNewagg <- aggregate (dataNew, by = ... mean) It gives following error : Error in aggregate.data.frame(datNew, by = list("x", "y", : arguments must have same length
asked Dec 6, 2019 alecxe 7.5k points