- maxi<-vector()
- chimax<-vector()
- for (i in 1:tcl) {
- maxi[i]<-which.max(chicroise)
- chimax[i]<-chicroise[maxi[i]]
- chicroise[maxi[i]]<-0
- }
- testpres<-function(x,listcoord) {
- for (i in 1:length(listcoord)) {
- if (x==listcoord[i]) {
- return(-1)
- } else {
- a<-1
- }
- }
- a
- }
- c.len=nrow(chicroise)
- r.len=ncol(chicroise)
- listx<-c(0)
- listy<-c(0)
- rang<-0
- cons<-list()
- #on garde une valeur par ligne / colonne
- for (i in 1:length(maxi)) {
- #coordonnées de chi2 max
- x.co<-ceiling(maxi[i]/c.len)
- y.co<-maxi[i]-(x.co-1)*c.len
- a<-testpres(x.co,listx)
- b<-testpres(y.co,listy)
-
- if (a==1) {
- if (b==1) {
- rang<-rang+1
- listx[rang]<-x.co
- listy[rang]<-y.co
- }
- }
- cons[[1]]<-listx
- cons[[2]]<-listy
- }
+ doxy <- function(chicroise) {
+ listx <- NULL
+ listy <- NULL
+ listxy <- which(chicroise > 3.84, arr.ind = TRUE)
+ #print(listxy)
+ val <- chicroise[which(chicroise > 3.84)]
+ ord <- order(val, decreasing = TRUE)
+ listxy <- listxy[ord,]
+ #for (i in 1:nrow(listxy)) {
+ # if ((!listxy[,2][i] %in% listx) & (!listxy[,1][i] %in% listy)) {
+ # listx <- c(listx, listxy[,2][i])
+ # listy <- c(listy, listxy[,1][i])
+ # }
+ #}
+ xy <- list(x = listxy[,2], y = listxy[,1])
+ xy
+ }
+ xy <- doxy(chicroise)
+ print(xy)
+ listx <- xy$x
+ listy <- xy$y
+
+# maxi<-vector()
+# chimax<-vector()
+# for (i in 1:tcl) {
+# maxi[i]<-which.max(chicroise)
+# chimax[i]<-chicroise[maxi[i]]
+# chicroise[maxi[i]]<-0
+# }
+# testpres<-function(x,listcoord) {
+# for (i in 1:length(listcoord)) {
+# if (x==listcoord[i]) {
+# return(-1)
+# } else {
+# a<-1
+# }
+# }
+# a
+# }
+# c.len=nrow(chicroise)
+# r.len=ncol(chicroise)
+# listx<-c(0)
+# listy<-c(0)
+# rang<-0
+# cons<-list()
+# #on garde une valeur par ligne / colonne
+# for (i in 1:length(maxi)) {
+# #coordonnées de chi2 max
+# x.co<-ceiling(maxi[i]/c.len)
+# y.co<-maxi[i]-(x.co-1)*c.len
+# a<-testpres(x.co,listx)
+# b<-testpres(y.co,listy)
+#
+# if (a==1) {
+# if (b==1) {
+# rang<-rang+1
+# listx[rang]<-x.co
+# listy[rang]<-y.co
+# }
+# }
+# cons[[1]]<-listx
+# cons[[2]]<-listy
+# }