Tomate uva organico
osc <- read.delim("~/ARTICULO 1 DATOS - Copy/osc.txt")
## Warning in read.table(file = file, header = header, sep = sep, quote =
## quote, : incomplete final line found by readTableHeader on '~/ARTICULO 1
## DATOS - Copy/osc.txt'
data <- osc
#correlaccion de los datos de las variables fresco:gbrix
cor(osc[,2:21])
## NFRAM1 PRAM1 NFRAM2 PRAM2 NFRAM3
## NFRAM1 1.00000000 -0.34244878 0.07326329 -0.8322782 -0.777982961
## PRAM1 -0.34244878 1.00000000 0.63013120 0.6094887 -0.050072092
## NFRAM2 0.07326329 0.63013120 1.00000000 0.4890299 0.086187736
## PRAM2 -0.83227815 0.60948869 0.48902992 1.0000000 0.761139782
## NFRAM3 -0.77798296 -0.05007209 0.08618774 0.7611398 1.000000000
## PRAM3 -0.65026765 -0.49108721 -0.57783604 0.2785981 0.761522625
## NFRAM4 0.36735282 -0.82459445 -0.88991928 -0.8047688 -0.331421764
## PRAM4 -0.41631089 -0.18494638 -0.87228946 -0.1380458 -0.004048602
## RENDPLT -0.87228209 0.73295888 0.14456917 0.8163543 0.438234053
## ALT -0.80321673 0.44522132 -0.33712631 0.4849644 0.262914589
## DIATLL -0.27967812 0.53560567 -0.29162711 0.0309564 -0.384663985
## FIRZ -0.14671307 0.97064820 0.57472920 0.4010015 -0.288544553
## SST 0.15716707 -0.97996104 -0.71878596 -0.4973077 0.177900732
## SPAD -0.13392228 0.95200478 0.50039096 0.3457673 -0.341502394
## N 0.39815514 -0.85969574 -0.86330950 -0.8135327 -0.314908989
## P 0.22836050 -0.77072134 -0.95076714 -0.7204312 -0.266691995
## K -0.33818453 0.13108079 -0.68427624 -0.1209498 -0.241397923
## Ca 0.14473455 -0.61848477 -0.96959737 -0.6689268 -0.323644011
## Mg 0.21255263 -0.58536084 -0.94285323 -0.7168527 -0.411523021
## S 0.11333112 -0.54675166 -0.96302660 -0.6425101 -0.348146910
## PRAM3 NFRAM4 PRAM4 RENDPLT ALT
## NFRAM1 -0.6502677 0.36735282 -0.416310893 -0.8722821 -0.80321673
## PRAM1 -0.4910872 -0.82459445 -0.184946383 0.7329589 0.44522132
## NFRAM2 -0.5778360 -0.88991928 -0.872289463 0.1445692 -0.33712631
## PRAM2 0.2785981 -0.80476883 -0.138045782 0.8163543 0.48496442
## NFRAM3 0.7615226 -0.33142176 -0.004048602 0.4382341 0.26291459
## PRAM3 1.0000000 0.32646810 0.535993986 0.2161734 0.38502289
## NFRAM4 0.3264681 1.00000000 0.575289262 -0.5750181 -0.11285608
## PRAM4 0.5359940 0.57528926 1.000000000 0.3361268 0.74779886
## RENDPLT 0.2161734 -0.57501809 0.336126789 1.0000000 0.87496358
## ALT 0.3850229 -0.11285608 0.747798865 0.8749636 1.00000000
## DIATLL -0.1733238 0.01718469 0.657145744 0.5941863 0.78511142
## FIRZ -0.6487594 -0.70598134 -0.165324806 0.6026432 0.37304069
## SST 0.6467041 0.82446674 0.328668439 -0.5830963 -0.27065374
## SPAD -0.6454943 -0.63932095 -0.089164086 0.5989590 0.41150800
## N 0.3262594 0.99740080 0.521424667 -0.6235021 -0.17622132
## P 0.4118182 0.98730753 0.695987556 -0.4382986 0.04403046
## K 0.2080744 0.38914500 0.925273473 0.4527655 0.80854997
## Ca 0.3663355 0.94055615 0.807967941 -0.2811551 0.21816370
## Mg 0.2766880 0.93656747 0.782444008 -0.3081008 0.19051237
## S 0.3374765 0.90925250 0.841280766 -0.2156132 0.28410889
## DIATLL FIRZ SST SPAD N
## NFRAM1 -0.27967812 -0.1467131 0.15716707 -0.13392228 0.39815514
## PRAM1 0.53560567 0.9706482 -0.97996104 0.95200478 -0.85969574
## NFRAM2 -0.29162711 0.5747292 -0.71878596 0.50039096 -0.86330950
## PRAM2 0.03095640 0.4010015 -0.49730771 0.34576726 -0.81353267
## NFRAM3 -0.38466398 -0.2885446 0.17790073 -0.34150239 -0.31490899
## PRAM3 -0.17332383 -0.6487594 0.64670413 -0.64549432 0.32625943
## NFRAM4 0.01718469 -0.7059813 0.82446674 -0.63932095 0.99740080
## PRAM4 0.65714574 -0.1653248 0.32866844 -0.08916409 0.52142467
## RENDPLT 0.59418635 0.6026432 -0.58309632 0.59895905 -0.62350210
## ALT 0.78511142 0.3730407 -0.27065374 0.41150800 -0.17622132
## DIATLL 1.00000000 0.6145161 -0.45502631 0.67988824 -0.05372442
## FIRZ 0.61451612 1.0000000 -0.98048962 0.99568660 -0.74428644
## SST -0.45502631 -0.9804896 1.00000000 -0.95806019 0.85147825
## SPAD 0.67988824 0.9956866 -0.95806019 1.00000000 -0.68225413
## N -0.05372442 -0.7442864 0.85147825 -0.68225413 1.00000000
## P 0.12422959 -0.6684113 0.80070255 -0.59658928 0.97561821
## K 0.89091487 0.1944943 -0.01260802 0.27529744 0.32210891
## Ca 0.33200457 -0.5071895 0.66668892 -0.42514160 0.91410373
## Mg 0.36468673 -0.4545318 0.61991906 -0.36997524 0.90895715
## S 0.41395741 -0.4320048 0.60084398 -0.34671244 0.87708823
## P K Ca Mg S
## NFRAM1 0.22836050 -0.33818453 0.1447346 0.2125526 0.1133311
## PRAM1 -0.77072134 0.13108079 -0.6184848 -0.5853608 -0.5467517
## NFRAM2 -0.95076714 -0.68427624 -0.9695974 -0.9428532 -0.9630266
## PRAM2 -0.72043125 -0.12094980 -0.6689268 -0.7168527 -0.6425101
## NFRAM3 -0.26669199 -0.24139792 -0.3236440 -0.4115230 -0.3481469
## PRAM3 0.41181824 0.20807436 0.3663355 0.2766880 0.3374765
## NFRAM4 0.98730753 0.38914500 0.9405562 0.9365675 0.9092525
## PRAM4 0.69598756 0.92527347 0.8079679 0.7824440 0.8412808
## RENDPLT -0.43829864 0.45276550 -0.2811551 -0.3081008 -0.2156132
## ALT 0.04403046 0.80854997 0.2181637 0.1905124 0.2841089
## DIATLL 0.12422959 0.89091487 0.3320046 0.3646867 0.4139574
## FIRZ -0.66841127 0.19449429 -0.5071895 -0.4545318 -0.4320048
## SST 0.80070255 -0.01260802 0.6666889 0.6199191 0.6008440
## SPAD -0.59658928 0.27529744 -0.4251416 -0.3699752 -0.3467124
## N 0.97561821 0.32210891 0.9141037 0.9089571 0.8770882
## P 1.00000000 0.50927369 0.9771189 0.9662869 0.9545745
## K 0.50927369 1.00000000 0.6775418 0.6820433 0.7372460
## Ca 0.97711889 0.67754183 1.0000000 0.9955064 0.9960980
## Mg 0.96628686 0.68204326 0.9955064 1.0000000 0.9948027
## S 0.95457447 0.73724597 0.9960980 0.9948027 1.0000000
# Componentes principales y estandarizar los datos, excepto cuando todo tenga las mismas unidades.
PCs <- prcomp(data[-1:-9],scale=T)
summary(PCs)
## Importance of components:
## PC1 PC2 PC3 PC4
## Standard deviation 2.6027 2.0827 0.94238 2.439e-15
## Proportion of Variance 0.5645 0.3615 0.07401 0.000e+00
## Cumulative Proportion 0.5645 0.9260 1.00000 1.000e+00
PCs
## Standard deviations:
## [1] 2.602724e+00 2.082725e+00 9.423825e-01 2.438772e-15
##
## Rotation:
## PC1 PC2 PC3 PC4
## RENDPLT 0.21398932 0.3137406406 0.54400703 0.364417162
## ALT 0.04301128 0.4210816752 0.49584159 -0.434386205
## DIATLL 0.03141989 0.4707159963 -0.19036482 0.070285473
## FIRZ 0.30761292 0.2398205898 -0.35115346 0.561882924
## SST -0.34590551 -0.1628155595 0.28959092 0.165317953
## SPAD 0.28514179 0.2716959022 -0.38114567 -0.503770901
## N -0.38026373 0.0007633701 -0.15174271 -0.091913347
## P -0.37603833 0.0959629225 -0.04924589 -0.142296902
## K -0.12661568 0.4529362775 0.04117897 0.008550403
## Ca -0.35077020 0.1930881524 -0.07339170 0.141448733
## Mg -0.34366900 0.2002918302 -0.17076486 0.052327989
## S -0.33556556 0.2303940330 -0.08843833 0.158825688
#Vectores de carga
PCs$rotation
## PC1 PC2 PC3 PC4
## RENDPLT 0.21398932 0.3137406406 0.54400703 0.364417162
## ALT 0.04301128 0.4210816752 0.49584159 -0.434386205
## DIATLL 0.03141989 0.4707159963 -0.19036482 0.070285473
## FIRZ 0.30761292 0.2398205898 -0.35115346 0.561882924
## SST -0.34590551 -0.1628155595 0.28959092 0.165317953
## SPAD 0.28514179 0.2716959022 -0.38114567 -0.503770901
## N -0.38026373 0.0007633701 -0.15174271 -0.091913347
## P -0.37603833 0.0959629225 -0.04924589 -0.142296902
## K -0.12661568 0.4529362775 0.04117897 0.008550403
## Ca -0.35077020 0.1930881524 -0.07339170 0.141448733
## Mg -0.34366900 0.2002918302 -0.17076486 0.052327989
## S -0.33556556 0.2303940330 -0.08843833 0.158825688
#Despliegue los primeros renglones de los vectores de récords
head(PCs$x)
## PC1 PC2 PC3 PC4
## [1,] -3.2498817 -1.2786624 0.5280398 2.775558e-17
## [2,] 2.5469575 0.5094777 1.0462372 -3.996803e-15
## [3,] 1.5816528 -1.9416562 -0.9478275 1.013079e-14
## [4,] -0.8787287 2.7108409 -0.6264495 2.498002e-15
#Grafica con los porcentajes de varianzas explicadas para los componentes
PCs_var <- PCs$sdev^2
porc_var <- PCs_var/(sum(PCs_var))
plot(porc_var,main="%de varianzas",col="salmon4", xlab="PC's",ylab="% varianzas PC's",type="b",lwd=2)
porc_var_acum <- cumsum(porc_var)
#Grafica con los porcentajes acumulados de varianzas explicadas
porc_var_acum <- cumsum(porc_var)
plot(porc_var_acum,main="% acumulados de Varianzas",col="tomato4",xlab="PC's",ylab="% varianzas PC's",type="b",lwd=2)
# Construccion del biplot
biplot (PCs, col=c("black","blue"), xlab="PC1 (56.45 %)",ylab="PC2 (36.15 %)", cex= c(1,.8))
abline(h=0, v=0 , col="black",cex= c(1,.7))
#Score
scores <- PCs$x
scores
## PC1 PC2 PC3 PC4
## [1,] -3.2498817 -1.2786624 0.5280398 2.775558e-17
## [2,] 2.5469575 0.5094777 1.0462372 -3.996803e-15
## [3,] 1.5816528 -1.9416562 -0.9478275 1.013079e-14
## [4,] -0.8787287 2.7108409 -0.6264495 2.498002e-15
#Cluster Dendograma
#Prepare hierarchical cluster
#score.cp <- read.delim("F:/ARTICULO Y CONGRESO/score.cp.txt")
#data <- score.cp
#attach(data)
#di <- dist(data[-1], method="euclidean")
#tree <- hclust(di, method="ward.D")
#data$hcluster <- as.factor((cutree(tree, k=3)-2) %% 3 +1)
# Agrupaccion de los hermanos mas proximos
#plot(tree, xlab="")
#datos <- read.delim("F:/ARTICULO Y CONGRESO/datos.txt")
#attach(datos)
#datos