[Solved] Pairs function doesn’t work in R


Echoing @DWin, it is not clear what Y is, given that it will try and get Y from your workspace.

If you mean to set the pch by the column Y within banknote, then the following will work

pairs(banknote[,-c(1,7)], 
  panel = function(x,y,...){
    points(x,y,pch = ifelse(as.logical(banknote$Y), 0,15))})

enter image description here

If you don’t want to have to reference the data.frame and column using $ then you could wrap everything within a with(banknote, ...) statement, then R will look within banknote to find the variables first

So the following will work

with(banknote, pairs(list(Left = Left, Right = Right, Bottom = Bottom, 
        Top = Top, Diagonal = Diagonal), 
      panel = function(x,y) points(x,y, pch= ifelse(as.logical(Y),0,15))) 

2

solved Pairs function doesn’t work in R