# [R] Question about position in row and column

Date: Thu 09 Nov 2006 - 13:08:36 GMT

Hi R-users,

I have 48 blocks like below

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20
21 22 23 24
25 26 27 28
29 30 31 32
33 34 35 36
37 38 39 40
41 42 43 44
45 46 47 48

in each block there are 18 cloumns and 18 rows which give 18*18*48 observations. The matrix looks like

```     1 2 3 .... 17 18 1 2 3. ..1 7 18 1 2 3. ..1 7 18 1 2 3  ... 17 18
1
2     Block 1         Block 2           block 3              Block 4
```
3
.
.

17
18

1
2 block 5 block 6 block 7 block 8   3
.
.

17
18

1
2
3 block 9 block 10 block11 block12
.
.

17
18

1
2
3 block 13 block 14 block 15 block 16
.
.

17
18

.
.
.

til the last row with blocks 45 46 47 48

What i want to do is to add column and row positions to block 2-48 so that the matrix will look like

1 2 3....17 18 19 20 21...35 36 37 38 39 ...53 54 55 56 ...71 72   1

```  2   block 1           block 2                 block 3        block 4
```
3
.
.

17
18

19
```  20  block 5        block 6                     block 7      block 8
```
21
.
.

35
36

37
38
39
.
.

53
54

55
56
57
.
.

71
72

.
.
.
.
.

198
199 block 45 block 46 block 47 block 48
.
.

215
216

How can I do this in R ?

I try

layout is a matrix contains columns:block, row, column, id name

## Column positions ###

blockcol<-rep(0,nrow(layout))
if(layout\$Block%%4==2)
{blockcol=layout\$Column+18}

if(layout\$Block%%4==3){blockcol=layout\$Column+36} else {blockcol=layout\$Column+54}

## Row positions ###

blockrow<-rep(0,nrow(layout))
if(layout\$Block<=4) {blockrow=layout\$Row}

```          for (j in 2:12){
if((j-1)*4<layout\$Block<=j*4)
{blockrow=layout\$Row+(j-1)*18}
}

```

but didn't get the desirable result.

Jenny

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri Nov 10 10:18:38 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 09 Nov 2006 - 23:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.