#Removemos todos los objetos de la memoria# rm(list=ls(all=TRUE)) biplot<-"Biplot" errorTxt<-"errorTxt" centroides <-"Centroides" coeficientes<-"Coeficientes" datosOut <-"Datos Out" histograma <-"Histograma" resultadoTxt<-"Resultado" frecuencias <-"Frecuencias" sedimentacion <-"Sedimentacion" #MINIDALENIUS# MINI.DALENIUS<-function(datos=x,estrato=2) { x<-sort(datos); L<-estrato; nclass<-min(L*10,length(x)); cla <- x[1] + (x[length(x)] - x[1]) * ((0:nclass)/nclass) cla[nclass + 1] <- cla[nclass + 1] + 1 factor.c <- vector(length = length(x)) for (i in 1:nclass) { factor.c[x >= cla[i] & x < cla[i + 1]] <- i } freq.c <- rep(0, nclass) pres.c <- tapply(x, factor.c, length) freq.c[as.numeric(names(pres.c))] <- as.vector(pres.c) csfreq.c <- cumsum(sqrt(freq.c)) but <- csfreq.c[nclass]/L nclass.temp <- vector(length = 2^(L - 1) - 1) csfreqh.temp <- rep(0, 2^(L - 1)) nclassh <- ssfreqh <- matrix(0, L, 2^(L - 1)) sous <- 0 k <- 1 for (i in 1:(L - 1)) { k1 <- k for (j in 1:length(sous)) { a <- csfreq.c - sous[j] b <- a[a > 0 & a < but] nclass.temp[k] <- length(b) k <- k + 1 } nclassh[i,] <- rep(c(t(cbind(nclass.temp[k1:(k-1)],nclass.temp[k1:(k-1)]+1))),each=(2^(L-2))/(k-k1)) cumnclass <- colSums(nclassh[1:i, , drop = FALSE]) cumss <- csfreqh.temp csfreqh.temp[cumnclass != 0] <- csfreq.c[cumnclass] csfreqh.temp[cumnclass == 0] <- 0 ssfreqh[i, ] <- csfreqh.temp - cumss pos <- seq(1, 2^(L - 1), (2^(L - 2))/(k - k1)) sous <- colSums(ssfreqh)[pos] } nclassh[L, ] <- nclass - cumnclass ssfreqh[L, ] <- csfreq.c[nclass]-sous out <- apply(nclassh <= 0, 2, any) very<-(ssfreqh[, !out] - but) #segundo filtro# if(is.matrix(very)==TRUE) { nrgr <- order(colSums((ssfreqh[, !out] - but)^2))[1] bhfull <- cla[cumsum(c(1, nclassh[, !out][, nrgr]))] IC<-matrix(rep(0,2*L),ncol=2) for(j in 1:L) { IC[j,1]<-bhfull[j]; IC[j,2]<-bhfull[j+1]; } factor.c <- vector(length = length(x)) for (i in 1:L) { factor.c[x >= bhfull[i] & x < bhfull[i + 1]] <- i } if(length(table(factor.c))==L) { temp<-"SI"; return(temp) } else {temp<-"NO";return(temp)} } #TERMINA EL SEGUNDO FILTRO# else { temp<-"NO"; return(temp) } #TERMINA LA FUNCIÓN PRINCIPAL# } #MINI.DALENIUS(ind,9); #-----------------------------------------------------------------------------# princomp.colli<- function(x, cor=FALSE, scores=TRUE, subset=rep(TRUE, nrow(as.matrix(x)))) { # it is tempting to add use="all.obs" which could be passed to cov or # cor but then the calculation of N is complicated. z<- as.matrix(x)[subset,, drop=F] N <- nrow(z) if(cor) cv <- get("cor",envir=.GlobalEnv)(z) else cv <- cov(z) #(svd can be used but gives different signs for some vectors) edc <- eigen(cv) cn <- paste("Comp.", 1:ncol(cv), sep="") names(edc$values) <- cn dimnames(edc$vectors) <- list(dimnames(x)[[2]], cn) scr<- NULL #------------------------------------------------------------------------------# cuenta<-0; for(i in 1:nrow(edc$vectors)) { if (edc$vectors[i]<0) {cuenta<-cuenta+1} } if (cuenta==nrow(edc$vectors)) { vectors<-(edc$vectors)*(-1) } else { vectors<-edc$vectors } #-------------------------------------------------------------------------------# if (cor) {sdev <- sqrt(edc$values) sc <- (apply(z,2,var)*(N-1)/N)^0.5 if (scores) scr<-(scale(z,center=T,scale=T) %*% vectors)*sqrt(N/(N-1)) } else { sdev <- sqrt(edc$values*(N-1)/N) sc <- rep(1, ncol(z)) if (scores) scr<- (scale(z,center=T,scale=F) %*%vectors) } names(sc) <- dimnames(x)[[2]] edc <-list(sdev=sdev, loadings=vectors,center=apply(z,2,mean), scale=sc, n.obs=N, scores=scr) # The Splus function also return list elements factor.sdev, correlations # and coef, but these are not documented in the help. coef seems to equal # load. The Splus function also return list elements call and terms which # are not supported here. class(edc) <- "princomp" edc } print.princomp <- function(x) { cat("Standard deviations:\n") print(x$sdev) cat(length(x$scale), " variables and ", x$n.obs, "observations.\n") cat("Scale:\n") print(x$scale) invisible(x) } #princomp.colli(x,cor=TRUE,scores=TRUE); library(sp) library(lattice) #Esta función revisa si todas las variables en el análsis estan altamente correlacionadas# cor.func<-function(x) { x.cor<-cor(x) dim.col<-ncol(x.cor) cal.acum<-0; for(i in 1:dim.col) { for(j in 1:dim.col) { if(j!=i) { if(x.cor[i,j]>=0.9) { cal.acum<-cal.acum+1 } } } } if(cal.acum==(dim.col*dim.col-dim.col)) { corre<-1} else {corre<-0} return(corre) } #Funcion nueva para colinialidad # revisa.cor<-function(tipo,x) { if (tipo=="Cor") { y<-as.matrix(log(det(cor(x)))) } if (tipo=="Cov") { y<-as.matrix(log(det(cov(x)))) } return(y) } #Grafica de centroides# plot.centroides<-function(datosx) { datosx.ncol<-ncol(datosx); conteo<-table(datosx[,datosx.ncol]) clust.name<-as.matrix(as.numeric(rownames(as.matrix(conteo)))) estrato<-nrow(clust.name) Centroides<-matrix(rep(NA,estrato*(datosx.ncol-1)),ncol=(datosx.ncol-1)) for (i in 1:estrato) { datosx.parte<-datosx[datosx[,datosx.ncol]==clust.name[i],] Centroides[i,]<-colMeans(datosx.parte[,-datosx.ncol]) } xnames<-colnames(datosx) colnames(Centroides)<-as.matrix(xnames)[-datosx.ncol,] direcentroides<-paste(centroides,".pdf",sep="") direcentroidesjpg<-paste(centroides,".jpg",sep="") pdf(file=direcentroides) matplot(Centroides,lty=1,type="b",pch=19,col=1:datosx.ncol,bg=10,main = "Centroides por variable",xlab="Estrato",ylab="Valores de los centroides",xaxt="n") axis(1,clust.name) leg.txt<-as.matrix(xnames)[-datosx.ncol,]; legend("topright", leg.txt, lty=1,pch =19, col= c(1:(datosx.ncol-1)),cex=1) dev.off() jpeg(filename=direcentroidesjpg,width = 500, height = 500,quality = 75,units = "px",bg = "white") matplot(Centroides,lty=1,type="b",pch=19,col=1:datosx.ncol,bg=10,main = "Centroides por variable",xlab="Estrato",ylab="Valores de los centroides",xaxt="n") axis(1,clust.name) leg.txt<-as.matrix(xnames)[-datosx.ncol,]; legend("topright", leg.txt, lty=1,pch =19, col= c(1:(datosx.ncol-1)),cex=1) dev.off() } #Salidas cuando no tenemos resultados# noobs<-function() { #library(maptools) #set.seed(123) x = c(0,0,0,0,0,5) y = c(10,9,8,7,6,0) w = c("LOS RESULTADOS NO SE GENERARON PORQUE EL NÚMERO DE", "VARIABLES SUPERA EL NÚMERO DE OBSERVACIONES, O BIEN,", "TODAS LAS VARIABLES ESTAN ALTAMENTE CORRELACIONADAS.", "SE SUGIERE INCLUIR MENOS VARIABLES EN EL MODELO", "O CAMBIAR AL MENOS UNA VARIABLE.", "" ) direcodos<-paste(sedimentacion,".pdf",sep="") #Grafica de codos# pdf(file=direcodos); par(ann = FALSE, xpd = NA, mar = rep(2, 4)) plot(x, y, type = "n", axes = FALSE) pointLabel(x, y, w, cex=c(rep(1,4),1)) dev.off() #grafica de cargas# direcargas<-paste(coeficientes,".pdf",sep="") pdf(file=direcargas) par(ann = FALSE, xpd = NA, mar = rep(2, 4)) plot(x, y, type = "n", axes = FALSE) pointLabel(x, y, w, cex=c(rep(1,4),1)) dev.off() #Bibplot# direbibplot<-paste(biplot,".pdf",sep="") pdf(file=direbibplot) par(ann = FALSE, xpd = NA, mar = rep(2, 4)) plot(x, y, type = "n", axes = FALSE) pointLabel(x, y, w, cex=c(rep(1,4),1)) dev.off() #Histograma# direhist<-paste(histograma,".pdf",sep="") pdf(file=direhist) par(ann = FALSE, xpd = NA, mar = rep(2, 4)) plot(x, y, type = "n", axes = FALSE) pointLabel(x, y, w, cex=c(rep(1,4),1)) dev.off() direcentroides<-paste(centroides,".pdf",sep="") pdf(file=direcentroides) par(ann = FALSE, xpd = NA, mar = rep(2, 4)) plot(x, y, type = "n", axes = FALSE) pointLabel(x, y, w, cex=c(rep(1,4),1)) dev.off() } #noobs(direout); #Agregando formato de negritas a las cargas# carga.negra<-function(loads) { loads<-round(loads,digits=3) for(i in 1:ncol(as.matrix(loads))) { parte<-loads[,i] if (i==1) { carga.ini<-as.matrix(rep(1,nrow(as.matrix(parte)))) for(j in 1:nrow(as.matrix(parte))) carga.ini[j,]<-paste("",parte[j],"") carga<-cbind(carga.ini) } else {carga<-cbind(carga,parte)} } carga<-data.frame(carga); names<-c(colnames(loads)); nombres<-c(colnames(loads)); #nombres[1]<-paste("
Variable | ")} else {cat("",colna[(i-1)]," | ")} } cat("\n"); dat<-cbind(rowna,dat) fila<-nrow(dat);colum<-ncol(dat); for(i in 1:fila) { for(j in 1:colum) { if(j==1 & i==1){cat("|
",dat[i,j]," | ")} else if(j==1 & i>1){cat("||
",dat[i,j]," | ")} else if(j==colum){cat("",dat[i,j]," | ","\n")} else {cat("",dat[i,j]," | ")} } } cat("
",dat[i,j],"   | ")} else if(j==1 & i>1){cat("||
",dat[i,j],"   | ")} else if(j==colum){cat("",dat[i,j]," | ","\n")} else {cat("",dat[i,j]," | ")} } } cat("
|
","\n")
cat("
","\n")
cat("
Intervalos para cada uno de los estratos generados a partir de la primera","\n")
cat(" componente principal:
","\n")
cat("
","\n")
fila<-nrow(limites);colum<-ncol(limites);
cat("
Limite inferior | Limite superior | ","\n") for(i in 1:fila) { for(j in 1:colum) { if(j==1){cat("|
",limites[i,j]," | ")} else if(j==colum){cat("",limites[i,j]," | ","\n")} else {cat("",limites[i,j]," | ")} } } cat("
",estra[j]," | ")} else if(j==colum){cat("",estra[j]," | ","\n")} else {cat("",estra[j]," | ")} } for(j in 1:colum) { if(j==1){cat("
",meanh[j]," | ")} else if(j==colum){cat("",meanh[j]," | ","\n")} else {cat("",meanh[j]," | ")} } cat("
",estra[j]," | ")} else if(j==colum){cat("",estra[j]," | ","\n")} else {cat("",estra[j]," | ")} } for(j in 1:colum) { if(j==1){cat("
",meanh[j]," | ")} else if(j==colum){cat("",meanh[j]," | ","\n")} else {cat("",meanh[j]," | ")} } cat("
",round(cum$stderr,digits=3)," | ") cat(" |
|
","\n")
cat("Valor de la prueba:",kmo ,"
");
cat(" Nota: Es deseable que este valor sea cercano a 1. ","\n")
};
Bartlett.sphericity.test <- function(x)
{
method <- " Prueba de esfericidad de Bartlett's"
data.name <- deparse(substitute(x))
x <- subset(x, complete.cases(x)) # Omit missing values
n <- nrow(x)
p <- ncol(x)
chisq <- (1-n+(2*p+5)/6)*log(det(cor(x)))
df <- p*(p-1)/2
p.value <- pchisq(chisq, df, lower.tail=FALSE)
names(chisq) <- "X-squared"
names(df) <- "df"
return(structure(list(statistic=chisq, parameter=df, p.value=p.value,
method=method, data.name=data.name), class="htest"))
}
#Damos de alta las librerias necesarias
library(foreign)
library(stratification)
#library(xlsReadWrite)
#library(relimp)
#library(gWidgets)
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
Analisis_componentes<-function(diredata,direout,tipo,numout,numgraf,estrato)
#Analisis_componentes<-function(rs,tipo,numout,numgraf,estrato)
{
#setwd(direout)
#Importamos descriptores#
DIRE.DECRIP<-paste(direout,"DescriptoresSel.dbf",sep="")
DESCRIP<-as.matrix(read.dbf(file=DIRE.DECRIP));
#DESCRIP<-as.matrix(rsDescriptores);
descripcion<-function()
{cat("
Descriptores para cada variable seleccionada:
", "\n \n");
for(i in 1:nrow(DESCRIP))
{ temp<-DESCRIP[i]
cat("
",temp,"\n");
}
cat("
","\n");
# print(DESCRIP);cat("\n");
}
#IMPORTAMOS LA BASE DE DATOS EN FORMATO CSV
#-------------------------------------------------------------------------#
#Eliminamos los valos NA, este valor es creado desde delphi#
#origen<-as.matrix(read.dbf(file=diredata));
origen<-read.dbf(file=diredata);
#origen<-rs;
for (i in 1:ncol(origen))
{
origen<-origen[origen[,i]!="NA",]
origen<-origen[origen[,i]!=-88,]
origen<-origen[origen[,i]!=-77,]
origen<-origen[origen[,i]!=-99,]
origen<-origen[origen[,i]!=-66,]
}
origen<-data.frame(origen)
#origen<-origen[,1:8]
#-----------------------------------------------------------------------#
ncolumnas<-ncol(origen) #numero de columnas
nfilas<-nrow(origen) #numero de filas
namecol<-colnames(origen)#nombres de las columnas originales#
#Obtenemos el nivel de los desgloses #
nname<-length(namecol)
vname<-as.matrix(rep(NA,nname),ncol=1,nrow=nname)
for (i in 1:nname)
{temp<-namecol[i]
if (temp=="ent"){vname[i]<-1}
else if (temp=="ent"){vname[i]<-1}
else if (temp=="CVEGEO"){vname[i]<-1}
else if (temp=="OID"){vname[i]<-1}
else if (temp=="clavegeo"){vname[i]<-1}
else if (temp=="mun"){vname[i]<-1}
else if (temp=="loc"){vname[i]<-1}
else if (temp=="ageb"){vname[i]<-1}
else {vname[i]<-0}
}
retro<-sum(vname)
nume<-origen[,(retro+1):ncolumnas]
for (i in 1:(ncolumnas-retro))
{ parte<-as.numeric(as.matrix(nume[,i]))
if (i==1){ numericas<-cbind(parte) }
else { numericas<-cbind(numericas,parte) }
}
nombres<-c(colnames(nume))
colnames(numericas)<-nombres
datos<-cbind(origen[,c(1:retro)],data.frame(numericas))
ncols<-ncol(datos) #numero de columnas
nfilas<-nrow(datos) #numero de filas
colnames(datos)<-namecol
#obtenemos la base de datos numericos#
x<-datos[,c((retro+1):ncols)]
xncol<-ncol(x);xnrow<-nrow(x);
#Agregamos nuevo codigo 27/03/2012#
cuenta<-0;
constante<-0;
for(i in 1:ncol(x))
{
if( length(table(x[,i]))>estrato ){cuenta<-cuenta+1}
if( length(table(x[,i]))==1 ){constante<-1}
}
#criterio:almenos una variable es constante#
if (constante==0)
{
if(ncol(x)==cuenta)
{
#---------------------------------------------------#
#Revisión de la correlación de los datos#
val.cor<-revisa.cor("Cor",x);
correlacion<-cor.func(x)
if (val.cor=="NaN" | correlacion==1 ){calif<-0}
else if (val.cor!="NaN" & correlacion==0 ){calif<-1}
#segunda condición#
if (calif==1)
{
#tercera condición #
if(xncol<=xnrow)
{
#Obtenemos el desglose
desglose<-datos[,c(1:retro)]
#Analisis de componentes principales#
#Formula#
fmla<-formulas(x);
fmlas<-as.formula(fmla)
if (tipo=="Cor")
{
comprin<-princomp.colli(x,cor=TRUE,scores=TRUE); xvar<-cor(x);
}
if (tipo=="Cov")
{
#datos estandarizados
#y<-as.matrix(x)
#z<-estandar(y)
comprin<-princomp.colli(x,cor=FALSE,scores=TRUE);xvar<-var(x);
}
#espectral<-eigen(xvar);
eigenvalue<-comprin$sdev^2
value<-matrix(rep(NA,length(eigenvalue)),ncol=1,nrow=length(eigenvalue))
acumula<-matrix(rep(NA,length(eigenvalue)),ncol=1,nrow=length(eigenvalue))
suma<-sum(eigenvalue)
for (i in 1:length(eigenvalue))
{
value[i,1]<-(eigenvalue[i]/suma)*100;
acumula[i,1]<-sum(value[1:i,1]);
}
#Matriz de eigenvalores y Porcentaje de varianzas
resultado<-cbind(eigenvalue,value,acumula)
colnames(resultado)=c("Valores característicos","Porcentaje de la varianza explicada","Porcentaje de la varianza explicada acumulada ")
resultado
#Matriz de componentes principales#
#cargas#
loads<-comprin$loadings
for(i in 1:ncol(as.matrix(loads)))
{
parte<-loads[,i]
if (i==1) {carga<-cbind(parte)}
else {carga<-cbind(carga,parte)}
}
nombres<-c(colnames(loads));
colnames(carga)<-nombres
componente<-carga
#ESTRATIFICANDO EL INDICADOR POR DALENIUS-HODGES#
minimo<-min((as.numeric(as.matrix(x)%*%as.matrix(componente[,1]))))
if (minimo>=0) {minimo<-0}
ind<-(as.numeric(as.matrix(x)%*%as.matrix(componente[,1])))-minimo;
correla<-MINI.DALENIUS(ind,estrato);
# Agregamos la condición de bandera blanca para correrla#
#cuarta condición#
if(correla=="SI")
{
nclase=min(estrato*10,length(ind));
#-------------------------------------------------------------------------#
if (nclase<=30){nclase<-30}
ind<-as.numeric(as.matrix(ind))
error<-try(cum<-strata.cumrootf(ind,nclass=nclase,CV=0.01,Ls=estrato,alloc=c(0.5,0,0.5)),silent=TRUE)
list.error<-unlist(strsplit(as.character(error), " ", fixed = TRUE))
true.error<-list.error[1]
if (true.error=="Error" | true.error=="c(0,")
{
dir.error<-paste(errorTxt,".html",sep="")
sink(dir.error) #redirige la salida al fichero salida.txt
cat("
Error:Este error ocurre porque se incluyo una variable que tiene una varianza","\n")
cat("aproximadamente cero, o bien, no se pueden generar todos los estratos deseados.","\n")
cat("Se recomienda reducir el numero de estratos. ","\n");cat("","\n");
cat("
El error que regresa la consola de R es:","","\n")
cat("
")
print(error);
cat("")
sink()
}
else
{
cum<-strata.cumrootf(ind,nclass=nclase,CV=0.01,Ls=estrato,alloc=c(0.5,0,0.5))
#------------------------------------------------------------------------#
resucum<-summary(cum);
#PRUEBA DE HIPOTESIS#
#kmt<-kmo(x)
bartlett<-Bartlett.sphericity.test(x)
#---------------INICIALIZAMOS LAS SALIDAS AL OUTPUT--------------------------#
titulo<-function()
{
cat("
|
","\n")
cat("Antes de utilizar los resultados de la estratificación multivariada, se sugiere","\n");
cat("analizar detalladamente los resultados del modelo.","\n");cat("
","\n");
cat("El INEGI no se hace responsable del uso, aplicación e interpretación de los re");
cat("sultados obtenidos en el análisis.","\n");cat("","\n");
cat("
|
","\n")
cat("Resultados del análisis de componentes principales usado para la estratificación","\n")
cat("con el método Dalenius-Hodges. (Ésta estratificación considera únicamente la ","\n");
cat("primera componente principal)","\n");cat("\n");
cat("\n");
cat("
|
","\n")
}
propo<-function()
{ cat("\n");
cat("
Porcentaje de la varianza explicada por la primera componente principal
")
print(round(resultado[1,2],digits=3));cat("
");
cat("  Nota: Es deseable que este valor sea próximo al 100%.","\n");cat("
","\n")
}
direresultado<-paste(resultadoTxt,".html",sep="")
#resumen corto #
Standard_deviations<-t(as.matrix(comprin$sdev))
if(numout==4)
{
sink(direresultado) #redirige la salida al fichero salida.txt
titulo();cat("\n");propo();cat("\n")
modelo(fmla,tipo); resumen(comprin);cat("\n") ;descripcion();
cat("\n"); cat("\n");cat("\n");
dalenius(ind,cum)
cat("\n");cat("\n");cat("\n")
kmo(x);cat("\n");cat("\n")
# print(bartlett);cat("\n");cat("\n")
sink() #redirige a la salida por defecto (pantalla)
}
#Importancia de los componentes#
tstd<-t(Standard_deviations)
importancia<-cbind(eigenvalue,tstd,value,acumula)
colnames(importancia)=c("Valores característicos","Desviación estándar","Porcentaje de la varianza explicada",
"Porcentaje de la varianza explicada acumulada ")
dat<-t(as.matrix(importancia))
importance<-function(dat)
{
dat<-round(dat,digits=3)
colna<-as.matrix(colnames(dat))
rowna<-as.matrix(rownames(dat))
cat("
Importancia de las componentes principales:
","\n")
cat("
","Descriptor"," | ")} else {cat("",colna[(i-1)]," | ")} } cat("\n"); dat<-cbind(rowna,dat) fila<-nrow(dat);colum<-ncol(dat); for(i in 1:fila) { for(j in 1:colum) { if(j==1){cat("|
",dat[i,j]," | ")} else if(j==colum){cat("",dat[i,j]," | ","\n")} else {cat("",dat[i,j]," | ")} } } cat("
","\n") cat(" Los datos no permiten generar este número de estratos. Intente con un número menor.
","\n") sink()#cerramos el texto# } #termina la tercera condición# } else { direresultado<-paste(resultadoTxt,".html",sep=""); sink(direresultado); cat("LOS RESULTADOS NO SE GENERARON PORQUE EL NÚMERO DE VARIABLES SUPERA EL","\n") cat("NÚMERO DE OBSERVACIONES, O BIEN, TODAS LAS VARIABLES ESTAN ALTAMENTE","\n") cat("CORRELACIONADAS. SE SUGIERE INCLUIR MENOS VARIABLES EN EL MODELO O ","\n") cat("CAMBIAR AL MENOS UNA VARIABLE.
","\n") sink()#cerramos el texto# #noobs(); } } #termina la segunda condición # else { direresultado<-paste(resultadoTxt,".html",sep=""); sink(direresultado); cat("LOS RESULTADOS NO SE GENERARON PORQUE EL NÚMERO DE VARIABLES SUPERA EL","\n") cat("NÚMERO DE OBSERVACIONES, O BIEN, TODAS LAS VARIABLES ESTAN ALTAMENTE","\n") cat("CORRELACIONADAS. SE SUGIERE INCLUIR MENOS VARIABLES EN EL MODELO O ","\n") cat("CAMBIAR AL MENOS UNA VARIABLE.
","\n") sink()#Cerramos el texto# # noobs() } } #termina la primera condición# else { direresultado<-paste(resultadoTxt,".html",sep=""); sink(direresultado); cat("","\n") cat("Los datos no permiten generar este número de estratos. Intente con un número menor.
","\n") sink()#Cerramos el texto# } } #termina criterio:almenos una variable es constante# else { direresultado<-paste(resultadoTxt,".html",sep=""); sink(direresultado); cat("","\n") cat("El indicador es constante para esta selección, por lo que no se pueden conformar estratos.
","\n") sink()#Cerramos el texto# } } #Analisis_componentes("E:/componentes R oscar duran/multiStrat.dbf","E:/componentes R oscar duran/resultado/","Cor",1,1,6);