Skip to content
Prev 22588 / 398502 Next

Level sets of factors are different (panel.superpose)

I investigated why I was getting this error message...

Error in Ops.factor(groups[subscripts], vals[1]) : 
	Level sets of factors are different

which led me to putting a browser in panel.superpose:

Called from: panel.superpose(x, y, subscripts, ...)
Browse[1]> vals
vals
[1] 1 2 3
Levels:  1 2 3 
Browse[1]> groups[subscripts]
groups[subscripts]
 [1] 1 2 3 1 2 1 2 3 1 2 3 1 2 3
Levels:  1 2 3 

this is the line that would fall over (in a for loop)
Browse[1]> id <- (groups[subscripts] == vals[i])

so I investigated...

Browse[1]> id <- (groups[subscripts] == vals[1])
id <- (groups[subscripts] == vals[1])
Error in Ops.factor(groups[subscripts], vals[1]) : 
	Level sets of factors are different



I've not had this problem before, so I'm guessing that in this case,
it had something to do with the fact that level 3 was missing in the
second instance.

I couldn't see why the logical couldn't work that out so I tried
something that is often necessary with lists in Splus (3.4 anyway).  I
changed the line to

id <- as.vector(groups[subscripts]) == as.vector(vals[i])

and it works (at least it doesn't fall over -- I haven't done a
thorough check to see if it really is working correctly).

Is that what is to be expected?  I can't follow why.

best