由买买提看人间百态

topics

全部话题 - 话题: rowptr
(共0页)
D******n
发帖数: 2836
1
来自主题: Statistics版 - a R loop question
This is definitely worth some baozis...
kf=c(0,1,0,0,0,1,1,0,0,0,0,0)
kf=matrix(kf,3)
nrow <- nrow(kf);
ncol <- ncol(kf);
oripos <- which(t(kf)==1,arr.ind=T)[,1];
nowpos <- oripos;
rowptr <- 1;
cat(nowpos,'\n');
while (rowptr<=nrow)
{
if ( nowpos[rowptr] { nowpos[rowptr] = nowpos[rowptr]+1;
rowptr = 1;
cat(nowpos,'\n');
}
else {
nowpos[rowptr] = oripos[rowptr];
rowptr = rowptr + 1;
}
}
(共0页)