R – non-numeric matrix extent error when plotting in R

r

When running the code of this example I'm getting the following error in the last line:

Error in matrix(mean(range), ncol = ncol(x), nrow = nrow(x), dimnames
= dimnames(x)) : non-numeric matrix extent

However, I remember having seen other cases some months ago where the library arulesViz worked whit categorical data type.

landing.data=read.csv2("http://archive.ics.uci.edu/ml/machine-learning-databases/shuttle-landing-control/shuttle-landing-control.data", 
                           sep=",", header=F, dec=".")
    landing.data=as.data.frame(sapply(landing.data,gsub,pattern="\\*",replacement=10))
    library(arules)
    landing.system <- as(landing.data, "transactions")
    rules <- apriori(landing.system, parameter=list(support=0.01, confidence=0.6))
    rulesLandingManual <- subset(rules, subset=rhs %in% "V1=1" & lift>1.2)
    library(arulesViz)
    plot(head(sort(rulesLandingManual, by="confidence"), n=3),
         method="graph",control=list(type="items"))

Best Answer

Doing a traceback() after running your code gives this:

6: matrix(mean(range), ncol = ncol(x), nrow = nrow(x), dimnames = dimnames(x))
5: map(m, c(5, 20))
4: graph_arules(x, measure = measure, shading = shading, control, 
       ...)
3: plot.rules(head(sort(rulesLandingManual, by = "confidence"), 
       n = 3), method = "graph", control = list(type = "items"))
2: plot(head(sort(rulesLandingManual, by = "confidence"), n = 3), 
       method = "graph", control = list(type = "items"))
1: plot(head(sort(rulesLandingManual, by = "confidence"), n = 3), 
       method = "graph", control = list(type = "items"))

So, basically the error comes from 6:. And the error implies that any of the argument matrix(.) are not numeric. To illustrate this:

> matrix(1:4, ncol=2)

#      [,1] [,2]
# [1,]    1    3
# [2,]    2    4

> matrix(1:4, ncol="x")
# Error in matrix(1:4, ncol = "x") : non-numeric matrix extent

You see the error? I don't think there's nothing much YOU can do here as the package extends graph, map and matrix to objects of class rules. So, this probably has a lot to do with the developer side. If it is indeed the case, probably it is worth writing/contacting the developers.

Related Topic