0

I have a row of values that I partition into a table.

row = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
rowPartitioned = Partition[row, 6]

{{1, 2, 3, 4, 5, 6}, {7, 8, 9, 10, 11, 12}}

Now I want to partition again to get the result

{{1, 2}, {7, 8}, {3, 4}, {9, 10}, {5, 6}, {11, 12}}

How could I do the second partitioning?

Another example :

Starting with the 210 value row, with values 1 to 210, the output nested table would have 6 columns and 35 rows:
(1-6) (31-36) (61-66) (91-96) (121-126) (151-156) (181-186) (7-12) (37-42) (67-72) (97-102) (127-132) (157-162) (187-192) (13-18) (43-48) (73-78) (103-108) (133-138) (163-168) (193-198) (19-24) (49-54) (79-84) (109-114) (139-144) (169-174) (199-204) (25-30) (55-60) (85-90) (115-120) (145-150) (175-180) (205-210)

andre314
  • 18,474
  • 1
  • 36
  • 69
Jamie M
  • 503
  • 2
  • 7

2 Answers2

1
Riffle @@ (Partition[#, 2] & /@ rowPartitioned)

which gives output:

{{1, 2}, {7, 8}, {3, 4}, {9, 10}, {5, 6}, {11, 12}}

Is that what you mean?

  • Hi, yes. I am trying to get a general solution for larger rows, for example, the row of values 1 to 210 (210 values). First partitioning that into 7 equal parts (1 to 30),(31 to 60),..(181 to 210). Then partition each of those 30 value rows into 5 equal parts, each 6 columns by 5 rows, and join all the data so the final nested table result would have 6 columns and 35 rows. The final nested table first column values are: 1,31,61,91,121,151,181,7,37,67,97,127,157,187,13,43,73,103,133,163,193,19,49,79,109,139,169,199,25,55,85,115,145,175,205. – Jamie M Jan 15 '19 at 23:51
1

Does this provide what you're looking for?

matrix = Flatten[Transpose[Partition[#, 6] & /@ Partition[Range[210], 30]], 1]

If you want it to display as a table, you can use:

matrix//MatrixForm

The first row matrix[[1]] gives {1,2,3,4,5,6}, the second matrix[[2]] gives {31,32,33,34,35,36}, and the first column matrix[[All, 1]] gives {1,31,61,91,121,151,181,7,37,67,97,127,157,187,13,43,73,103,133,163,193,19,49,79,109,139,169,199,25,55,85,115,145,175,205}.

MassDefect
  • 10,081
  • 20
  • 30