15

i am trying to plot a ROC curve for a multiclass problem, using multiclass.roc function from pROC package, but I get this error:

'x' is a list, but does not have components 'x' and 'y'

What does this error mean cause searching in the web didn't help me to find an answer. I can print the roc object, but can not plot it.

Thank you!

student
  • 161
  • 1
  • 1
  • 5
  • 1
    Please provide a reproducible example. Paste the output from `dput(yourdata)` and the code that generated the error. – Backlin Aug 17 '12 at 10:28

2 Answers2

13

If you call plot on a list l: plot (l), the x coordinates will be taken from l$x and the y coordinates from l$y. Your list doesn't have elements x and y.

You need to call plot (l$your.x.coordinate, l$your.y.coordinate) instead.

cbeleites unhappy with SX
  • 13,717
  • 5
  • 45
  • 57
1

Another (lazy) approach is to simply use the useful library

install.packages('useful')
library(useful)

Example -

wineUrl <- 'http://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data'
wine <- read.table(wineUrl, header=F, sep=',')
wine_kmeans <- wine[, which(names(wine) != "Cultivar")]
wine_cluster <- kmeans(x=wine_kmeans , centers=3)
plot(wine_cluster, data=wine_kmeans)

enter image description here

Pirate X
  • 3,023
  • 5
  • 33
  • 60
  • Which function from useful is called in your example? I only see plot.kmeans (implied in the plot function), but I don't think that is related to the original question. – Tripartio Sep 29 '22 at 16:00