[Rd] list/matrix chimera
Tony Plate
tplate at blackmesacapital.com
Tue Apr 10 19:03:24 CEST 2007
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
More information about the R-devel
mailing list