What does this mean: unable to find an inherited method for function ‘A’ for signature ‘ B ’
That is the type of message you will get when attempting to apply an S4 generic function to an object of a class for which no defined S4 method exists (or at least has been attached to the current R session).
Here's an example using the raster package (for spatial raster data), which is chock full of S4 functions.
library(raster)
## raster::rotate() is an S4 function with just one method, for "Raster" class objects
isS4(rotate)
# [1] TRUE
showMethods(rotate)
# Function: rotate (package raster)
# x="Raster"
## Lets see what happens when we pass it an object that's *not* of class "Raster"
x <- 1:10
class(x)
# [1] "integer"
rotate(x)
# Error in (function (classes, fdef, mtable) :
# unable to find an inherited method for function ‘rotate’ for signature ‘"integer"’
Unable to find an inherited method for function ‘select’ for signature ‘ data.frame ’
There's a great package that helps with package conflicts called conflicted.
If you type search()
into your console, you'll see an ordered vector of packages called the "search list". When you call select
, R searches through this "search path" and matches the first function called select
. When you call dplyr::select
you're calling it directly from the namespace dplyr
, so the function works as expected.
Here's an example using conflicted
. We'll load up raster and dplyr, which both have a select
function.
library(dplyr)
library(raster)
library(conflicted)
d <- data.frame(a = 1:10, b = 1:10)
Now when we call select
, we're 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")
Unable to find an inherited method for function 'dbClearResult' for signature ' data.frame '
dbClearResult
applies to the query
object, not to the result
of the fetch (which is a dataframe
, hence the error message):
query <- dbSendQuery(db_con,...)
result <- dbFetch(query, n = -1)
dbClearResult(query)
dbDisconnect(db_con)
R unable to find an inherited method for function 'itemFrequency' for signature ' data.frame '
I see that you are trying to implement Apriori algorithm.
To find the itemFrequency of the items in your data set
itemFrequency(mydata)
Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "itemFrequency", for signature "data.frame"
Solution:
step1. load the necessary packages and library like arules, arulesViz
step2. Let say you trying to bring votes data and you need to read the data as transactions
votes <- read.transactions("~/Desktop/votes.csv")
if you just write votes you will have a summary of your transactions as follow
votes
transactions in sparse format with
435 transactions (rows) and
342 items (columns)
Now you can easily find the itemFrequency
itemFrequency(votes)
Here is a sample imageitemFrequency(votes)
democrat 245
republican
345
Hope this will help!
Related Topics
Avoid String Printed to Console Getting Truncated (In Rstudio)
Equivalent to Unix "Less" Command Within R Console
How to Make Gradient Color Filled Timeseries Plot in R
Convert Four Digit Year Values to Class Date
Delete "" from CSV Values and Change Column Names When Writing to a CSV
Create Frequency Tables for Multiple Factor Columns in R
Adding New Columns to a Data.Table By-Reference Within a Function Not Always Working
Generate Paired Stacked Bar Charts in Ggplot (Using Position_Dodge Only on Some Variables)
Directly Creating Dummy Variable Set in a Sparse Matrix in R
Data.Frame Without Ruining Column Names
Replace Values in a Vector Based on Another Vector
Group Integer Vector into Consecutive Runs
R Function Not Returning Values
Add Max Value to a New Column in R
Number of Significant Digits in Dplyr Summarise
R Package Lattice Won't Plot If Run Using Source()