Bonjour,

Je suis en train de faire un programme avec des conditions "else if" mais ca ne marche pas...
J'ai une erreur qui dit else in else...

Savez-vous pourquoi? Et si oui, pouvez-vous m'aider?


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
indice=c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10,1.2, 2.4, 3.6, 4.8, 6, 7.2, 8.4, 9.6, 10.8, 12,1.4, 2.8, 4.2, 5.6, 7, 8.4, 9.8, 11.2, 12.6, 14,1.6, 3.2, 4.8, 6.4, 8, 9.6, 11.2, 12.8, 14.4, 16,1.8, 3.6, 5.4, 7.2, 9, 10.8, 12.6, 14.4, 16.2, 18,2, 4, 6, 8, 10, 12, 14, 16, 18, 20,2.2, 4.4, 6.6, 8.8, 11, 13.2, 15.4, 17.6, 19.8, 22,2.4, 4.8, 7.2, 9.6, 12, 14.4, 16.8, 19.2, 21.6, 24,2.6, 5.2, 7.8, 10.4, 13, 15.6, 18.2, 20.8, 23.4, 26,2.8, 5.6, 8.4, 11.2, 14, 16.8, 19.6, 22.4, 25.2, 28,
         3, 6, 9, 12, 15, 18, 21, 24, 27, 30)
mat31415=matrix(indice,11,10,byrow=T)
 
seuils=c(304.15,294.15,306.15,296.15,308.15,298.15,310.15,300.15,312.15,302.15,314.15,304.15,316.15,306.15,318.15,308.15,320.15,310.15,322.15,312.15,324.15,314.15)
 
matseuil=matrix(seuils,11,2,byrow=T)
 
indextype=c(2,rep(c(1,2),30))
 
data <- read.table("source.csv", sep=";", dec=",", quote="\"")
 
newDataFrame = matrix(NA,400,61)
 
for (i in 1:dim(newDataFrame)[1]) {
  s=1
  for (j in 1:dim(newDataFrame)[2]){
    if(data[i,j]< 292.15 & (s==1) & indextype[j]==2)
    {
      newDataFrame[i,j]=0
    } 
 
		else if(data[i,j] < 302.15 && (s == 1) && indextype[j] == 1)
		newDataFrame[i,j]=0 else
				if(data[i,j]<292.15 && (s!=1) && indextype[j]==2)
			newDataFrame[i,j]=mat31415[k,s-1] else
				if(data[i,j]<302.15 && (s!=1) && indextype[j]==1)
           newDataFrame[i,j]=mat31415[k,s-1] else
				if(indice<length(mat31415)+1)
			newDataFrame[i,j]= mat31415[k,s] else
				if(data[i,j]>=292.15 & indextype[j]==2 || data[i,j]>=302.15 & indextype[j]==1) 
 
 
              {
                k=1
                while(data[i,j]> matseuil[k,indextype[j]])
                {
                  k=k+1
                }
 
                newDataFrame[i,j]= mat31415[k,s]
                s=s+1
              }
  }
}
 
write.table.....