Data Transformation



Hi Everyone:

Could anyone please help me solve the following problem.

I have an original data set with multiple attributes. It
needs to be transformed as shown below. The following is
an example:

original transformed
Id x y Id x y
1 8 4 1 32 37
2 9 9 2 39 55
3 2 5 3 8 46
4 7 19 4 32 55
5 7 15 5 39 46
6 3 10 6 8 37
7 11 18 7 33 41
8 15 16 8 28 43
9 1 17 9 18 54
10 8 9 10 28 54
11 6 9 11 33 41
12 2 7 12 18 43

I need to divide the original data into 4 matrices in order
(from rows 1-3, 4-6, etc.) and sort each matrix
separately, so I have loaded each part separately (without
row ids) each with the same number of rows (the number of
rows in the last matrix can be different, if the original
data cannot be divided into 4 equal parts) as follows. I
am showing the row ids because I need to keep track of
them for data transformation. My function looks like
this: function r = datatrans
(input_file_1,input_file_2,input_file_3,input_file_4,output
_file);
When I sort each matrix , it should be something like
below. The ids of x and y will be different because each
attribute is sorted individually.

id x id y id x id y id x id y id x id y
3 2 1 4 6 3 6 10 9 1 8 16 12 2 12 7
1 8 3 5 4 7 5 15 7 11 9 17 11 6 10 9
2 9 2 9 5 7 4 19 8 15 7 18 10 8 11 9

However because I have loaded each matrix separately, the
row id for the 2nd, 3rd and 4th matrices also become 1,2,
and 3. But I need to keep the row ids as shown above
because, I need to transform the data as explained below:

I would like the x attribute values from the first row of
each matrix be the first row in the intermediate matrix,
the x values from the 2nd row of each matrix be the third
row in the intermediate matrix, the third row of each
matrix be the 5th row in the intermediate matrix as
follows. The rows in between are populated with values
from the rows above and below. For example, the second row
of the intermediate matrix will have the x values of 1st
row of the 3rd and 4th matrices and the x values of the
2nd row of 1st and 2nd matrices as follows. The last row
has the x values of the 3rd row of the 3rd and 4th
matrix and the 1st row of the 1st and 2nd matrices. Each
row x values are then added up and only the first two ids
are replaced with the sum, e.g. 3 & 6 in the original data
are replaced with 8, ids 9 and 12 with 18, 1 and 4 with 32
and so on as shown below.
id x id x id x id x sum(x)
3 2 6 3 9 1 12 2 8
9 1 12 2 1 8 4 7 18
1 8 4 7 7 11 11 6 32
7 11 11 6 2 9 5 7 33
2 9 5 7 8 15 10 8 39
8 15 10 8 3 2 6 3 28
similarly Y attribute intermediate matrix should be
id y id y id y id y sum(y)
1 4 6 10 8 16 12 7 37
8 16 12 7 3 5 5 15 43
3 5 5 15 9 17 10 9 46
9 17 10 9 2 9 4 19 54
2 9 4 19 7 18 11 9 55
7 18 11 9 1 4 6 10 41

The fully transformed data (and the final output)is shown
above.

I am not sure whether I am correct in loading the original
data as 4 separate matrices or whether there is another
method of virtually separating and sorting them after
loading the original data as is. I need to work with many
1000s of rows with multiple attributes.

Please help with some hints on how to transform the data
as indicated.

MANY THANKS FOR ANY HELP THAT I GET!



.



Relevant Pages

  • Re: Forced return??
    ... Change the commas in your original data to the equivalent of comma & CHAR ... You might splitt the original data into separate columns and use separate VLOOKUPs ... I'm looking for help on a wrapped cell. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Extracting Initials from Given names
    ... elegant, but a dummy like myself would do it this way:-) Assuming the names ... in each cell use a consistent separator, such as a (ie, John Allen ... the names into 3 separate columns. ... Let's say the original data begins in ...
    (microsoft.public.mac.office.excel)
  • Re: Sorting
    ... Click to get to the 3rd step of the TTC Wizard. ... This leaves your original data *untouched*, ... Now, just sort both columns on the number column, and then delete the ...
    (microsoft.public.excel)
  • Re: Sorting
    ... Please keep all correspondence within the NewsGroup, ... This leaves your original data *untouched*, ... Now, just sort both columns on the number column, and then delete the ...
    (microsoft.public.excel)
  • Re: SQL help !!!
    ... particular part of a text string as represents a unique ... >original post put the values into a delimited list in one ... >TRANSFORM SumAS daValue ... >> I also wonder how to separate those value into ...
    (microsoft.public.access.queries)