Sorry to bother everyone again with one question about array. I have one data set saved in this way

patient    time     x1      x2      response
1               1         1        8         1
1               2         2        7         1
2               1         3        6         1
2               2         4        5         1
3               1         5       4          2
3               2         6       3          2
4               1        7        2          2
4               2        8        1          2

I am wondering if there is any easy way to change the data into an array that 1st dimension is for variables (x1 and x2), 2nd is for patients (I would like to call it replicates), 3rd is for time (2 and 1), 4th is for response (2 and 1). The resulted array would look like as follows:

, , 1, 1

     [,1] [,2]
[1,]    1    3
[2,]    8   6

, , 2, 1

     [,1] [,2]
[1,]    2   4
[2,]    7   5

, , 1, 2

     [,1] [,2]
[1,]    5  7
[2,]   4   2

, , 2, 2

     [,1] [,2]
[1,]   6   8
[2,]   3   1


Thanks a lot,

Suyan

______________________________________________
R-help@r-project.org 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.

Reply via email to