I want to select the data which the third value of sublist is below certain value. So I tried to use Select function as below, but I'm struggling how to apply it to the deep level of the list.
part = Partition[RandomReal[10, 1500], 3];
threedata = {{part[[1 ;; 3]], part[[4 ;; 5]], part[[11 ;; 16]], part[[17 ;; 21]], part[[22 ;; 23]]}, {part[[24 ;; 25]], part[[26 ;; 30]], part[[31 ;; 40]], {part[[41]]}}, {part[[42 ;; 47]], {part[[48 ;; 51]]}}};
sel[list_, width_] :=
Module[{li = list, threash = width, sharp},
sharp = Select[li, #[[3]] < threash &]
];
The function can be used for the first component of the list as
sel[threedata[[1]][[#]], 3.0] & /@ Range[Length[threedata[[1]]]]
So I can get answer by
answer1={sel[#, 8.0] & /@ threedata[[1]], sel[#, 8.0] & /@ threedata[[2]], sel[#, 8.0] & /@ threedata[[3]]}
But I have two questions.
The function Select can take only the list of "True" and for "False (else)", only blanc list "{}" returns. How can I alter the blank list {} to {0,0,0}?
I want to know how to get the answer directly, not by doing each like
answer1={sel[#, 8.0] & /@ threedata[[1]], sel[#, 8.0] & /@ threedata[[2]], sel[#, 8.0] & /@ threedata[[3]]} ?
Furthermore, if the nest dimension become larger, such as the dataset below, what should I do?? I always have trouble in applying the function to the deepest position of the nest list.
dataset = {{{part[[100 ;; 105]], part[[108 ;; 109]]}, {part[[110 ;; 120]], part[[150 ;; 155]]}, {{part[[160]]}}}, {{part[[181 ;; 188]], part[[190 ;; 193]], part[[195 ;; 197]]}, {part[[200 ;; 205]], part[[208 ;; 209]]}}, {{part[[300 ;; 304]], part[[310 ;; 312]], part[[344 ;; 350]]}, {{part[[400]]}}}};