1 function resu = fold(df, dim, indr, indc)
3 %# function resu = subasgn(df, S, RHS)
4 %# The purpose is to fold a dataframe. Part from (1:indr-1) doesn't
5 %# move, then content starting at indr is moved into the second,
6 %# third, ... sheet. To be moved, there must be equality of rownames,
7 %# if any, and of fields contained in indc.
10 %% Copyright (C) 2009-2012 Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
12 %% This file is part of Octave.
14 %% Octave is free software; you can redistribute it and/or
15 %% modify it under the terms of the GNU General Public
16 %% License as published by the Free Software Foundation;
17 %% either version 2, or (at your option) any later version.
19 %% Octave is distributed in the hope that it will be useful,
20 %% but WITHOUT ANY WARRANTY; without even the implied
21 %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
22 %% PURPOSE. See the GNU General Public License for more
25 %% You should have received a copy of the GNU General Public
26 %% License along with Octave; see the file COPYING. If not,
27 %% write to the Free Software Foundation, 51 Franklin Street -
28 %% Fifth Floor, Boston, MA 02110-1301, USA.
31 %# $Id: fold.m 9585 2012-02-05 15:32:46Z cdemills $
35 [indr, nrow] = df_name2idx(df._name{1}, indr, df._cnt(1), 'row');
36 [indc, ncol] = df_name2idx(df._name{2}, indc, df._cnt(2), 'column');
39 slice_size = indr(1) - 1;
40 %# we can't use directly resu = df(1:slice_size, :, :)
42 S.subs = { 1:slice_size, ':', ':', 'dataframe'};
43 resu = subsref(df, S);
45 %# how many columns for each slice
46 targets = cellfun(@length, df._rep);
47 %# a test function to determine if the location is free
48 for indj = 1:df._cnt(2),
49 if (any(indj == indc)),
54 testfunc{indj} = @(x, indr, indc) ...
57 testfunc{indj} = @(x, indr, indc) ...
63 %# where does this line go ?
64 where = find(df._data{indc}(1:slice_size, 1) ...
65 == df._data{indc}(indi, 1));
67 %# transfering one line -- loop over columns
68 for indj = 1:df._cnt(2),
73 if (testfunc{indj}(resu._data{indj}, where, targets(indj))),
75 resu = df_pad(resu, 3, 1, indj);
76 targets(indj) = targets(indj) + 1;
80 resu._data{indj}(where, targets(indj)) = ...
81 df._data{indj}(indi, 1);
84 resu._ridx(where, max(targets)) = df._ridx(indi);
86 disp('line 65: FIXME'); keyboard;
92 disp('line 70: FIXME '); keyboard