Skip to content

lda

3 messages · T. Murlidharan Nair, Brian Ripley, Sundar Dorai-Raj

#
Hi !!
I am trying to analyze some of my data using  linear discriminant analysis.
I worked out the following example code in Venables and Ripley
It does not seem to be happy with it.
============================
library(MASS)
library(stats)
data(iris3)
ir<-rbind(iris3[,,1],iris3[,,2],iris3[,,3])
ir.species<-factor(c(rep("s",50),rep("c",50),rep("v",50)))
ir.lda<-lda(log(ir),ir.species)
ir.ld<-predict(ir.lda,dimen=2)$x
eqscplot(ir.ld, type="n", xlab = "First linear discriminant", ylab = 
"second linear discriminant")
text(ir.ld, labels= as.character(ir.species[-143]), col =3 
+codes(ir.species),cex =0.8)

======================================


eqscplot does not plot anything and it gives me an error 
saying codes is defunct. Have I missed anything there. 

Thanks../Murli
#
On Tue, 2 Nov 2004, T. Murlidharan Nair wrote:

            
What is `it'?  If you mean R, which version, and which version of the VR 
bundle?
That line is definitely not in `Venables and Ripley'
I have no idea why eqscplot is misbehaving (your example works up to the
last line for me), but the R scripts which the book refers you to do work.  
See p.12 (and the R posting guide asking you to read the relevant section
of the book).
#
T. Murlidharan Nair wrote:

            
Murli,
eqscplot gives you nothing because you specified `type="n"'. You are not 
plotting anything because your call to "text" never completed.

When I do this I get:

 > R.version.string
[1] "R version 2.0.0, 2004-10-09"
 > text(ir.ld, labels= as.character(ir.species[-143]), col =3 
+codes(ir.species),cex =0.8)
Error: 'codes' is defunct.
See help("Defunct")

This means "codes" is no longer available. Use ?as.integer instead.

--sundar

P.S. Please do read the posting guide and tell us what version of R you 
are using, etc.