Dear Researchers,

I wish to ask and help to write a good and elegant method to select a right
sequence in a matrix that i need to do a Remote Sensing Filter

prova <- t(matrix(seq(1:16), nrow=4,ncol=4))

> prova
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    5    6    7    8
[3,]    9   10   11   12
[4,]   13   14   15   16

# i need to do 2 sequence seq1 = 1,3,6,8,9,11,14,16 and
seq=2,4,5,7,10,12,13,15.
# I did the following loop but is not very elegant sorry

Truefalse <- list()

for(p in seq(1,4, by=2)){
    for(v in seq(2,4,by=2)){
            cv <- prova[p,]%%2!=0
            cx <- prova[v,]%%2==0
            Truefalse[[p]] <- cv
            Truefalse[[v]] <- cx
}
}

Truefalse
Truefalse.df <- as.data.frame(do.call("rbind",Truefalse))
prova.df <- as.data.frame(prova)

...............

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to