Jason Welter wrote: > > I have a list that looks like: > > data = {{1,1,a,4,5,6},{2,1,a,2,3,4},{3,1,a,7,8,9}, > {1,2,b,4,5,6},{2,2,b,2,3,4},{3,2,b,7,8,9}, > {1,3,c,4,5,6},{2,3,c,2,3,4},{3,3,c,7,8,9}} > > and I want to pick out the lists that have a 2 as the second element > of the list. I tried something like: > > data1 = Select[data,data[[#,2]]==2]; > > but this doesn't work. How do I do it? Try the following:
data = {{1,1,a,4,5,6},{2,1,a,2,3,4},{3,1,a,7,8,9}, {1,2,b,4,5,6},{2,2,b,2,3,4},{3,2,b,7,8,9}, {1,3,c,4,5,6},{2,3,c,2,3,4},{3,3,c,7,8,9}} data1 = Select[data,(#[[2]]==2)&]
Output: Out[58]= {{1, 1, a, 4, 5, 6}, {2, 1, a, 2, 3, 4}, {3, 1, a, 7, 8, 9}, {1, 2, b, 4, 5, 6}, {2, 2, b, 2, 3, 4}, {3, 2, b, 7, 8, 9}, {1, 3, c, 4, 5, 6}, {2, 3, c, 2, 3, 4}, {3, 3, c, 7, 8, 9}} Out[59]= {{1, 2, b, 4, 5, 6}, {2, 2, b, 2, 3, 4}, {3, 2, b, 7, 8, 9}}
I hope this helps.
Nate
