octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dataframe dereferencing


From: Jaroslav Hajek
Subject: Re: dataframe dereferencing
Date: Thu, 2 Sep 2010 21:04:28 +0200

On Thu, Sep 2, 2010 at 3:43 PM, Judd Storrs <address@hidden> wrote:
> On Thu, Sep 2, 2010 at 4:35 AM, CdeMills <address@hidden>
> wrote:
>>
>> x(1:3, 1:2)(:).cell
>> y = x(1:3, 1:2)(:)
>> z = y.cell
>
> I understand why you are doing this, but one thing to be aware of is that
> the idiomatic way to do casting is to call a constructor. e.g. this is how I
> would naively approach this based on how things are done in Matlab:
> cell(x(1:3, 1:2)(:))
> y = x(1:3, 1:2)(:)
> z = cell(y)
> For user-written classes, I think you can either provide @foo/foo.m or
> @dataframe/foo.m, but I'm not 100% certain because I haven't done this in a
> while.

Hi Judd,
while you have every right to naively expect this, understand that for
cell(x(1:3, 1:2)) the inner expression must result in some kind of
intermediary object (e.g. a sub-dataframe) which is then converted to
cell, while x.cell(1:3, 1:2) may be optimized so as to extract the
proper portion of data to cell directly. Similarly for matrix.
However, I see no reason why dataframe couldn't support conversion to
cell through cell (dataframe) as well.


> I'm very interested in dataframe but I haven't had a chance to look at it
> yet. Based only on this thread one question I had was whether dataframe
> already implement cell-style "{}" indexing in addition to the "()" indexing?
> If not, maybe that could be used to distinguish between the "I want the
> data" and "I want a dataframe subset" uses.
> x(1:3) # <-- return data if appropriate
> x{1:3} # <-- return truncated dataframe

Before you overload {} or suggest doing it, make sure you understand
the associated cs-list & numel issues.

regards

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]