X-Git-Url: http://iramuteq.org/git?a=blobdiff_plain;f=Rscripts%2FCHD.R;h=4e64b01bbb612648265ced9c2c8cb303118e08ca;hb=9ea4c8f11aae4e01a21f4b48231c56a915ead1cb;hp=974e90107aa8ee1404e760cedb5835a9738cee47;hpb=42a67a41b64a6e0cc3fd2a63a0749e9aa4b9374c;p=iramuteq diff --git a/Rscripts/CHD.R b/Rscripts/CHD.R index 974e901..4e64b01 100644 --- a/Rscripts/CHD.R +++ b/Rscripts/CHD.R @@ -1,6 +1,6 @@ #Author: Pierre Ratinaud -#Copyright (c) 2008-2011 Pierre Ratinaud -#Lisense: GNU/GPL +#Copyright (c) 2008-2020 Pierre Ratinaud +#License: GNU/GPL pp<-function(txt,val) { d<-paste(txt,' : ') @@ -26,17 +26,28 @@ find.max <- function(dtable, chitable, compte, rmax, maxinter, sc, TT) { lo[1:nrow(dtable)] <- 0 for (k in 1:nrow(ln)) {lo[[ln[k,1]]]<-append(lo[[ln[k,1]]],ln[k,2])} for (k in 1:nrow(dtable)) {lo[[k]] <- lo[[k]][-1]} - lo<-lo[-c(1,length(lo))] - for (l in lo) { - compte <- compte + 1 - chitable[1,l]<-chitable[1,l]+1 - chitable[2,l]<-chitable[2,l]-1 - chi<-MyChiSq(chitable,sc,TT) - if (chi>maxinter) { - maxinter<-chi - rmax<-compte - } - } + ## lo<-lo[-c(1,length(lo))] + ## for (l in lo) { + ## compte <- compte + 1 + ## chitable[1,l]<-chitable[1,l]+1 + ## chitable[2,l]<-chitable[2,l]-1 + ## chi<-MyChiSq(chitable,sc,TT) + ## if (chi>maxinter) { + ## maxinter<-chi + ## rmax<-compte + ## } + #} + lo<-lo[-c(1)] + for (l in lo) { + chi<-MyChiSq(chitable,sc,TT) + if (chi>maxinter) { + maxinter<-chi + rmax<-compte + } + compte <- compte + 1 + chitable[1,l]<-chitable[1,l]+1 + chitable[2,l]<-chitable[2,l]-1 + } res <- list(maxinter=maxinter, rmax=rmax) res } @@ -219,7 +230,7 @@ CHD<-function(data.in, x=9, mode.patate = FALSE, svd.method, libsvdc.path=NULL){ print('longueur < 0') malcl<-length(vdelta) if ((it>1)&&(!is.logical(listsub[[it]]))&&(!is.logical(listsub[[it-1]]))){ - if (listsub[[it]]==listsub[[(it-1)]]){ + if (all(listsub[[it]]==listsub[[(it-1)]])){ malcl<-0 } }