[Solved] ‘x’ is a list, but does not have components ‘x’ and ‘y’

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!

Enquirer: student


Solution #1:

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.

Solution #2:

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


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

Respondent: Pirate X

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.