From tplate at blackmesacapital.com  Tue Apr 10 19:03:24 2007
From: tplate at blackmesacapital.com (Tony Plate)
Date: Tue, 10 Apr 2007 11:03:24 -0600
Subject: [Rd] list/matrix chimera
In-Reply-To: <f8e6ff050704100930p444beafwe2b6ed1caf229927@mail.gmail.com>
References: <m2lkh0xp4i.fsf@fhcrc.org> <461BA714.5040009@blackmesacapital.com>
	<f8e6ff050704100930p444beafwe2b6ed1caf229927@mail.gmail.com>
Message-ID: <461BC35C.2070306@blackmesacapital.com>

hadley wickham wrote:
> 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
> 

Doesn't vv[[1,2]] do that?

-- Tony



[Rd] list/matrix chimera
Tony Plate