I have two equally long lists of equally large matrices . I now want to generate a column that consists of the differences between position [i,j] in matrix k in each list. That is, the first position in this new column is 'position [1,1] in matrix 1 (of list 1)' minus 'position [1,1] in matrix 1 (of list 2)', and so on, continuing to the next matrix as soon as the current one is searched through. It seems like an easy problem, but I cannot seem to get the loops correct. -- View this message in context: http://www.nabble.com/Operating-matrix-positions-tf4607032.html#a13155110 Sent from the R help mailing list archive at Nabble.com.
On Thu, 11 Oct 2007, Svempa wrote:> > I have two equally long lists of equally large matrices . I now want to > generate a column that consists of the differences between position [i,j] in > matrix k in each list. That is, the first position in this new column is > 'position [1,1] in matrix 1 (of list 1)' minus 'position [1,1] in matrix 1 > (of list 2)', and so on, continuing to the next matrix as soon as the > current one is searched through. > > It seems like an easy problem, but I cannot seem to get the loops correct.Perhaps you want this or its transpose : mapply( "-", list1, list2 ) Chuck> > -- > View this message in context: http://www.nabble.com/Operating-matrix-positions-tf4607032.html#a13155110 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
Still one problem remains. The list I have is a list where every element refers to a file, where the actual matrices are. This means problems with dealing with them. How do I turn the list of references into an actual vector with real matrices as components? See below for earlier details. Svempa wrote:> > I have two equally long lists of equally large matrices . I now want to > generate a column that consists of the differences between position [i,j] > in matrix k in each list. That is, the first position in this new column > is 'position [1,1] in matrix 1 (of list 1)' minus 'position [1,1] in > matrix 1 (of list 2)', and so on, continuing to the next matrix as soon as > the current one is searched through. > > It seems like an easy problem, but I cannot seem to get the loops correct. > >-- View this message in context: http://www.nabble.com/Operating-matrix-positions-tf4607032.html#a13174209 Sent from the R help mailing list archive at Nabble.com.