On 05/04/2010 3:20 PM, Trafim Vanishek wrote:
> Dear all,
> My question how is it possible to define a matrix A with 10 rows 1 column,
> so that its elements are vectors of undefined length.
> I need to have a possibility later to add elements like A[1,1] <-
> Thanks a lot for the help!
You create the matrix from a list:
I may be mistaken, but I don't think that's possible or even should be
possible. A matrix is m x n, where m and n are (kind of fixed) integers. You
cannot have a matrix where m(1) to m(n) (the row lengths) vary. If you want
to do this, you have to use a list instead (I believe).
As a poor workaround you could fill an m x n matrix with NAs or 0s (where n
is the anticipated maximum length among all rows) and then fill the rows
with the values. However, this is dirty as you will not be able to
distinguish true NAs or 0s at the end of a row from the ones you have used
to fill the dummy matrix in the first place; so the list is really the way