Skip to content
Prev 12556 / 398502 Next

pch with plot and legend

Hi
The simple answer is ...

    legend(locator(1),pch=1:2,legend=levels(supp))

... because the numeric equivalent of the levels of a factor are the
integers 1:nlevels(<factor>)

This might be viewed as a not very nice programming style because
it makes use of knowledge of the underlying implementation of factors.
A more complicated and harder to understand, but possibly more pure
solution might be ...

    legend(locator(1),pch=as.numeric(supp[match(levels(supp),
supp)]),legend=levels(supp))

Paul


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._