From h.wickham at gmail.com  Tue Apr 10 18:30:27 2007
From: h.wickham at gmail.com (hadley wickham)
Date: Tue, 10 Apr 2007 11:30:27 -0500
Subject: [Rd] list/matrix chimera
In-Reply-To: <461BA714.5040009@blackmesacapital.com>
References: <m2lkh0xp4i.fsf@fhcrc.org> <461BA714.5040009@blackmesacapital.com>
Message-ID: <f8e6ff050704100930p444beafwe2b6ed1caf229927@mail.gmail.com>

On 4/10/07, Tony Plate <tplate at blackmesacapital.com> wrote:
> Aren't you just seeing the effect of drop=TRUE? (at least with the
> examples you give below -- they all pick out a submatrix with extent one
> on some dimension)
>
> AFAICT, matrices with a list as the underlying data work properly, e.g.:
>
>  > vv <- array(as.list(1:12), 3:4)
>  > vv
>       [,1] [,2] [,3] [,4]
> [1,] 1    4    7    10
> [2,] 2    5    8    11
> [3,] 3    6    9    12
>  > vv[1:2,]
>       [,1] [,2] [,3] [,4]
> [1,] 1    4    7    10
> [2,] 2    5    8    11
>  > vv[1,,drop=FALSE]
>       [,1] [,2] [,3] [,4]
> [1,] 1    4    7    10
>  >
>
> It can actually be useful sometimes to have a matrix (or array) of
> non-atomic objects -- wouldn't your proposed change remove (or at least
> damage) that functionality?

I use this functionality a lot in the reshape package.  I would hate
to see it go!

It would be nice to have some way to remove the [[1]] from vv[1, 2][[1]] though.

Hadley



[Rd] list/matrix chimera
hadley wickham