I wrote an R package a few years ago to go with a paper I was writing, called PhiCor . This was working fine, but I recently had someone contact me as they couldn't get it to work with their version of R 4.1.1.
This is the most recent commit not working (so the code that isn't working can be accessed later:
Error in NextMethod("CorIndex"): no method to invoke
I have upgraded R and I can replicate the error. But I do not know why it isn't working. This is where the error is showing up:
CorIndex <- function(InDataframe, speciesbinary,weighted, group, SquareID = NULL){
speciesbinary = InDataframe[,speciesbinary]
weighted = InDataframe[,weighted]
group = InDataframe[,group]
NextMethod("CorIndex")
}
I then have numerous other functions:
CorIndex.default <- function(InDataframe, speciesbinary,weighted, group, SquareID = NULL){
CorIndex.TargetVar <- function(CorIndexVarInput, targetgroup){
CorIndex.groupEqual <- function(CorIndexTargetVarInput){
In particular, the one that was being run that triggered the error was:
CorIndex.all.plusP <- function(InDataframe, speciesbinary, weighted, group, numberIteration = 1000, SquareID = NULL, toroidal = FALSE){
Which was being run with the example data I included in the package:
Species1_AllPhiPvalues = CorIndex.all.plusP(InDataframe = Species1, speciesbinary = "Species1", weighted = 'Proportion', group = 'HabId', SquareID = 'LocationID')
For now I have simply done this:
CorIndex <- function(InDataframe, speciesbinary,weighted, group, SquareID = NULL){
speciesbinary = InDataframe[,speciesbinary]
weighted = InDataframe[,weighted]
group = InDataframe[,group]
#NextMethod("CorIndex")
CorIndex.default(InDataframe,speciesbinary,weighted, group, SquareID)
Bit of a bodge exposing my incomplete understanding of S3. Seems to work, but a bit scruffy and I am not sure a problem won't pop up somewhere else.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.