0

If we have a list (data1) of 201*201 members as {a,b,c} (which a,b and c are numeric), how can we save them into another list (data2) containing just c's in the groups of 100 member as (I can use of Last but the problem is gathering them to 100 member groups)

data1={{a1,b1,c1},{a2,b2,c2},....,{a201,b201,c201},......,{a40401,b40401,c40401}}
data2={{c1,c2,c3,......c100},{c101,c102,....c200},{c201,...c300},....}
Unbelievable
  • 4,847
  • 1
  • 20
  • 46
  • 2
    Use Map[], Last[], and Partition[]? – J. M.'s missing motivation Feb 18 '16 at 12:56
  • Out of curiosity, why not keep the c values in lists that are 201 elements long? That way you keep the original structure and you don't have to throw any away (as in, throwing out data point number 40401) – Jason B. Feb 18 '16 at 13:03
  • this question is related to my previous question and I wanted to generate a new list which is similar to proposed by @george2079 (and you alerted me about its structure) and apply the process. – Unbelievable Feb 18 '16 at 13:16
  • I could not add a note in previous question, your last answer about that was completely helpful, you wrote in a format understandable and translatable to me. Wonderful! – Unbelievable Feb 18 '16 at 13:24

3 Answers3

4
data2 = Partition[data1[[All, 3]], 100]

References:

http://reference.wolfram.com/language/ref/Part.html

http://reference.wolfram.com/language/ref/Partition.html

Pisto
  • 344
  • 1
  • 8
2

Examples:

(*arbitrary data*)
data = {{a1, b1, c1}, {a2, b2, c2}, {a3, b3, c3}};

(*Example No.1*)
data[[All, 3]][[1 ;; 3]]

(*Example No.2*)
Last @ # & /@ data

Additional information:

In Example No.1 data is the dataset you operate on. [[All,3]] selects third item from each nested list and [[1 ;; 3]] selects the range of data you are interested in.

Likewise, in Example No. 2 data is the dateset you operate on. Function Last is used to extract the last element from each sublist. For more information on syntax, please see Reference section below.

Output:

{c1, c2, c3}

Reference:

Part
@ # /@ etc.

e.doroskevic
  • 5,959
  • 1
  • 13
  • 32
1
data2 = Table[data1[[100 i - 99 ;; 100 i, 3]], {i, 1, 201}]
Hubble07
  • 3,614
  • 13
  • 23