Displaying 3 results from an estimated 3 matches for "testmat1".
Did you mean:
testmat
2008 Nov 10
1
comparing rows - a possible solution
Hello,
sorry for posting this independently of the original thread, but it is
not that easy to answer to mails, when receiving the r-help as
digest...
...
The question was:
> I compare each row of a matrix with each row of another matrix.
>
> testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
> testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
and it was asked for a compaison of the both matrix-objects and the
result should be a vetor with boolean results.
I would use this one:
as.vector( tes...
2008 Nov 10
2
Make one vector from matrix comparison
Hello R-users,
I have a little problem.
I compare each row of a matrix with each row of another matrix.
testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4)
Both matrix differs in the last row.
Now I create a loop:
for (i in (1:4)){
for (j in (1:4)){
b <- (c(setequal(testmat1[j,],testmat2[i,])))
print(b)
}
}
R...
2016 Apr 06
0
R-dvel [robustness Simulation study of 2 sample test on several combination of factors ]
..., Apr 6, 2016 6:52 PM wrote:
You are running through two loops and putting the output into a
vector. Without this calculation you will overwrite the same elements
of the output vector instead of advancing through it. Try this
example:
# like your 54 element vector of calculations for one condition
testmat1<-rep(0,25)
testmat2<-rep(0,25)
# now try to fill it with the inner loop index
for(i in 1:5) {
for(j in 1:5) {
testmat1[j]<-i+j
}
}
# do it again using a calculation similar to your question
for(i in 1:5) {
for(j in 1:5) {
testmat2[(i-1)*5+j]<-i+j
}
}
testmat1
testmat2
Try out s...