Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

plot

r

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!

like image 835
student Avatar asked Aug 17 '12 10:08

student


2 Answers

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.

like image 113
cbeleites unhappy with SX Avatar answered Oct 16 '22 20:10

cbeleites unhappy with SX


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

like image 1
Pirate X Avatar answered Oct 16 '22 18:10

Pirate X