[R] Matrix indexes

W. Beldman wgbeldman at student.han.nl
Mon Jan 12 10:15:50 CET 2004


Two questions about matrix indexing:

Is is correct that   V <- V[lower.tri(V, diag=TRUE)]   returns the lower 
triangular of matrix V, that is: all elements above diagonal are set to zero? I 
understand that the triangle of matrix elements of V for which lower.tri is 
TRUE are returned while the others (above diagonal) are set to zero (or NA ???).



If D and B are vectors of logicals,
what does  V  contain after   V <- v[D, B, drop=FALSE]   ?
I guess that elements are returned if both indexes D and B are TRUE, but I'm 
not really convinced... (And again, what about the other elements?)




These are probably tutorial questions, but I'm still not sure after reading "R 
Language Definition (draft): Evaluation of expressions" and applicable sections 
of "The R Reference Manual". Thanx!

W. Beldman




More information about the R-help mailing list