R语言程序求助
jlbl<-function(x,y){k<-vector(mode="numeric",length=0);t=1;a=2;b=1;c=1;yk[1]=1;for(ii...
jlbl<-function(x,y){
k<-vector(mode="numeric",length=0);
t=1;
a=2;
b=1;
c=1;y
k[1]=1;
for(i in 1:nrow(x)){
if(x[i,2]==x[i+1,2])
t=t+1;
if(x[i,2]!=x[i+1,2]){
k[a]=t;
s=k[a]-k[a-1];
if(s==1){
y[c,1]=x[i,2];
y[c,2]=x[i,3];
y[c,x[i,1]+2]=y[c,x[i,1]+2]+1;
c=c+1;
continue;
}
for(j1 in k[a-1]:k[a]){
for(j3 in b:c)
if(y[j3,2]==x[j1,3])
break;
bzw=1;
if(j1==k[a])
break;
for(j2 in j1+1:k[a]){
if(x[j2,3]==x[j1,3])
y[c,x[j1,1]+2]=y[c,x[j1,1]+2]+1;
}
if(bzw==1){
y[c,1]=x[j1,2];
y[c,2]=x[j1,3];
y[c,x[j1,1]+2]=y[c,x[j1,1]+2]+1;
c=c+1;
}
}
a=a+1;
}
b=c;
}
}
遇到问题提示:
Error in if (x[j2, 3] == x[j1, 3]) y[c, x[j1, 1] + 2] = y[c, x[j1, 1] + :
missing value where TRUE/FALSE needed 展开
k<-vector(mode="numeric",length=0);
t=1;
a=2;
b=1;
c=1;y
k[1]=1;
for(i in 1:nrow(x)){
if(x[i,2]==x[i+1,2])
t=t+1;
if(x[i,2]!=x[i+1,2]){
k[a]=t;
s=k[a]-k[a-1];
if(s==1){
y[c,1]=x[i,2];
y[c,2]=x[i,3];
y[c,x[i,1]+2]=y[c,x[i,1]+2]+1;
c=c+1;
continue;
}
for(j1 in k[a-1]:k[a]){
for(j3 in b:c)
if(y[j3,2]==x[j1,3])
break;
bzw=1;
if(j1==k[a])
break;
for(j2 in j1+1:k[a]){
if(x[j2,3]==x[j1,3])
y[c,x[j1,1]+2]=y[c,x[j1,1]+2]+1;
}
if(bzw==1){
y[c,1]=x[j1,2];
y[c,2]=x[j1,3];
y[c,x[j1,1]+2]=y[c,x[j1,1]+2]+1;
c=c+1;
}
}
a=a+1;
}
b=c;
}
}
遇到问题提示:
Error in if (x[j2, 3] == x[j1, 3]) y[c, x[j1, 1] + 2] = y[c, x[j1, 1] + :
missing value where TRUE/FALSE needed 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询