[R] lda

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Tue Nov 2 22:31:17 CET 2004



T. Murlidharan Nair wrote:

> 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

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.




More information about the R-help mailing list