You can do this...
# Some random data:
b_1 <- b_2 <- b_3 <- matrix(,2,3)
for(i in 1:3) eval(substitute(A <- matrix(rnorm(6), 2), list(A=paste('a', i,
sep=''
# the loop
for (i in 1:2) {
for (j in 1:3) {
for(k in 1:3) {
eval(substitute(A[i,j] <- rank(c(a1[i,j],a2[i,j],a
On Jan 18, 2010, at 9:21 PM, rusers.sh wrote:
> If the number of datasets for a* is small (here is 3), it is ok for
> creating b_ijn[i, j, nn] and make assignments to it. But it will be
> a little bit impossible for a larger number of datasets for a*, say
> 999. We may need 999 lines to do
On Jan 18, 2010, at 7:58 PM, David Winsemius wrote:
On Jan 18, 2010, at 7:19 PM, rusers.sh wrote:
Hi,
See example.
for (i in 1:2) {
for (j in 1:3) {
b_1[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[1]
b_2[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[2]
b_3[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))
If the number of datasets for a* is small (here is 3), it is ok for creating
b_ijn[i, j, nn] and make assignments to it. But it will be a little bit
impossible for a larger number of datasets for a*, say 999. We may need 999
lines to do this. Maybe there are other alternatives.
2010/1/18 David Win
On Jan 18, 2010, at 7:19 PM, rusers.sh wrote:
Hi,
See example.
for (i in 1:2) {
for (j in 1:3) {
b_1[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[1]
b_2[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[2]
b_3[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[3]
}
}
The inner codes is really repeated, so
Hi,
See example.
for (i in 1:2) {
for (j in 1:3) {
b_1[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[1]
b_2[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[2]
b_3[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[3]
}
}
The inner codes is really repeated, so i want to change the inner codes
into loop
6 matches
Mail list logo