I am trying to plot Banknote data frame from alr3 package.My pairs function throws me error and doesn’t give me correct plot when I execute it.Can someone tell me what’s going wrong here? Thanks.
Basically I am trying to write code to find out all the counterfeit banknotess from “banknote” data frame present in “alr3” package.
Code:-
pairs(banknote[,-1],panel=
function(x,y,fake){
xy <- cbind(x,y)
points(xy[fake==0,],pch=15)
points(xy[fake==1,],pch=0)
}, fake=Y)
Errors:-
Error in points(xy[fake == 0, ], pch = 15) :
(subscript) logical subscript too long
In addition: Warning messages:
1: In plot.window(...) : "fake" is not a graphical parameter
2: In plot.xy(xy, type, ...) : "fake" is not a graphical parameter
3: In title(...) : "fake" is not a graphical parameter
4: In plot.window(...) : "fake" is not a graphical parameter
5: In plot.xy(xy, type, ...) : "fake" is not a graphical parameter
6: In title(...) : "fake" is not a graphical parameter
7: In axis(side = side, at = at, labels = labels, ...) :
"fake" is not a graphical parameter
Echoing @DWin, it is not clear what
Yis, given that it will try and getYfrom your workspace.If you mean to set the
pchby the columnYwithinbanknote, then the following will workIf you don’t want to have to reference the
data.frameand column using$then you could wrap everything within awith(banknote, ...)statement, thenRwill look withinbanknoteto find the variables firstSo the following will work