Dear All,
Thank you for those of you who come up with a
solution for my problems. Special thanks to John Fox who came up with an
elegant solution!
Again assuming I have the same list:
list(matrix(rnorm(6,3,2),ncol=2),matrix(rnorm(8,3,2),ncol=2),matrix(rnorm(12,3,2),ncol=2))
[[1]]:
[,1] [,2]
[1,] 3.276729 -1.054961
[2,] 6.143453 2.661098
[3,] 3.952712 5.311158
[[2]]:
[,1] [,2]
[1,] 2.575617 2.513717
[2,] 1.657351 2.806912
[3,] 3.134966 3.357252
[4,] 3.832333 7.657893
[[3]]:
[,1] [,2]
[1,] 4.171555
1.67055950
[2,] -1.763487 1.42753060
[3,] 4.552255
2.78249251
[4,] -3.206052 0.49597245
[5,] -1.742525 4.01679075
[6,] 2.486436
0.05678951
I want to append a series of values to each items on
the list so they look like below, I have c(3,2,5,8,9,3,2,3,2,3,2,1,7) which I
would like to cbind to each item on the list so they
look like:
[[1]]:
[,1] [,2]
[,3]
[1,] 3.276729 -1.054961 3
[2,] 6.143453 2.661098
2
[3,] 3.952712 5.311158 5
[[2]]:
[,1] [,2] [,3]
[1,] 2.575617 2.513717 8
[2,] 1.657351 2.806912 9
[3,] 3.134966 3.357252 3
[4,] 3.832333 7.657893 2
[[3]]:
[,1] [,2] [,3]
[1,] 4.171555
1.67055950 3
[2,] -1.763487 1.42753060 2
[3,] 4.552255
2.78249251 3
[4,] -3.206052 0.49597245 2
[5,] -1.742525 4.01679075 1
[6,] 2.486436
0.05678951 7
My solution to this was to rbind
the list, then cbind this with c(3,2,5,8,9,3,2,3,2,3,2,1,7),
and then split the result into these three categories again using an index to
get the above list. It seems a bit funny to work through this process but I
cannot think of a better solution. Is there a quick way I can simply append the
values on to the list?
Thanks for your attention.
**************************************************************************************
Steve Su (s.su@qut.edu.au)
PhD student.
School of Accountancy
School of Mathematical Sciences
Queensland University of Technology
Postal Address: Steve Su, School of Accountancy, QUT, PO Box 2434, Brisbane,
Queensland, Australia, 4000.
Phone: +61 7 3864 2017
Fax: +61 7 3864 1812
Mobile: 0421 840
586
.
_--_|\
/
QUT
\_.--._/
v
**************************************************************************************