R version 2.11.1 (2010-05-31) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > date() [1] "Fri Feb 25 05:11:31 2011" > ################################################### > ### chunk number 2: int0 > ################################################### > dpoints <- matrix(c(-1,-1,2,-1,2,1,1,2), byrow=T, ncol=2) > colnames(dpoints) <- c("x","y") > dpoints <- data.frame(dpoints) > dpoints x y 1 -1 -1 2 2 -1 3 2 1 4 1 2 > plot(dpoints,type="n") > text(dpoints,lab=rownames(dpoints)) > abline(v=0, col=grey(0.6), lty=2) > abline(h=0, col=grey(0.6), lty=2) > > > ################################################### > ### chunk number 3: int1 > ################################################### > dptscent <- scale(dpoints, center=T, scale=F) > plot(dptscent,type="n") > text(dptscent,lab=rownames(dpoints)) > abline(v=0, col=grey(0.6), lty=2) > abline(h=0, col=grey(0.6), lty=2) > > > ################################################### > ### chunk number 4: int2 > ################################################### > dt <- dist(dptscent, method = "euclidean", diag = T, upper = T) > round(dt, digit=4) 1 2 3 4 1 0.0000 3.0000 3.6056 3.6056 2 3.0000 0.0000 2.0000 3.1623 3 3.6056 2.0000 0.0000 1.4142 4 3.6056 3.1623 1.4142 0.0000 > > > ################################################### > ### chunk number 5: int3 > ################################################### > matdt <- as.matrix(dt) > matH <- -matdt*matdt/2 > matH <- t(matH-colMeans(matH)) - rowMeans(matH) + mean(matH) > matH 1 2 3 4 1 5.5625 -0.4375 -2.9375 -2.1875 2 -0.4375 2.5625 0.0625 -2.1875 3 -2.9375 0.0625 1.5625 1.3125 4 -2.1875 -2.1875 1.3125 3.0625 > > > ################################################### > ### chunk number 6: int4 > ################################################### > library(ade4) Attaching package: 'ade4' The following object(s) are masked from 'package:base': within > bicenter.wt(-0.5*matdt*matdt) 1 2 3 4 1 5.5625 -0.4375 -2.9375 -2.1875 2 -0.4375 2.5625 0.0625 -2.1875 3 -2.9375 0.0625 1.5625 1.3125 4 -2.1875 -2.1875 1.3125 3.0625 > > > ################################################### > ### chunk number 7: int5 > ################################################### > eigen(matH)$values [1] 8.409853e+00 4.340147e+00 -6.149595e-16 -1.776357e-15 > eigen(matH)$values[1:2] -> valpro > > > ################################################### > ### chunk number 8: int6 > ################################################### > eigen(matH)$vectors[,1:2] -> vecpro > norme <- function(x) sum(x*x) > apply(vecpro,2,norme) [1] 1 1 > t(vecpro)*sqrt(valpro) [,1] [,2] [,3] [,4] [1,] 2.2391581 0.3232505 -1.2157677 -1.346641 [2,] 0.7407234 -1.5678039 -0.2905322 1.117613 > vecpro <- t( t(vecpro)*sqrt(valpro)) > colnames(vecpro) <- c("vecteur1","veteur2") > vecpro vecteur1 veteur2 [1,] 2.2391581 0.7407234 [2,] 0.3232505 -1.5678039 [3,] -1.2157677 -0.2905322 [4,] -1.3466409 1.1176127 > > > ################################################### > ### chunk number 9: int7 > ################################################### > plot(vecpro,type="n") > text(vecpro,lab=rownames(dpoints)) > abline(v=0, col=grey(0.6), lty=2) > abline(h=0, col=grey(0.6), lty=2) > dist(vecpro, method = "euclidean", diag = T, upper = T) 1 2 3 4 1 0.000000 3.000000 3.605551 3.605551 2 3.000000 0.000000 2.000000 3.162278 3 3.605551 2.000000 0.000000 1.414214 4 3.605551 3.162278 1.414214 0.000000 > > > ################################################### > ### chunk number 10: int8 > ################################################### > pco1 <- dudi.pco(dt, scannf=F, nf=2) > scatter(pco1) > > > > proc.time() user system elapsed 0.424 0.052 0.474