Questions tagged [list-manipulation]

Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.

Filter by
Sorted by
Tagged with
17 votes
7 answers
5k views

How to find rows that have maximum value?

Suppose if I have following list { {10,b,30}, {100,a,40}, {1000,b,10}, {1000,b,70}, {100,b,20}, {10,b,70} } How to find rows that have max value in ...
14 votes
3 answers
4k views

Flatten at a certain level

In an earlier question the brainteasing fourth syntax variant of Flatten was discussed. I see that with ...
15 votes
3 answers
5k views

Why don't * and ^ work as I expected on matrices? [closed]

For example, this input... {{1, 2}, {3, 4}}*{{1, 2}, {3, 4}} produces this output... {{1, 4}, {9, 16}} and this input... <...
  • 1,007
9 votes
4 answers
415 views

Unexpected behavior from GatherBy in version 7

Bug introduced in 7.0 or earlier and fixed in 8.0.4 or earlier I have come across what appears to be a bug in GatherBy. It appears similar to the problem of using ...
  • 265k
10 votes
2 answers
606 views

How to generate Intervals from a given list?

If I have a list list={3,7,4,5,1} how to get the List of Intervals /Ranges result = {{1,3},{3,4},{4,5},{5,7}}
12 votes
13 answers
2k views

How to find range in which a number falls, from given list of numbers?

How can one find the range in which a number falls, from given list of numbers? ...
18 votes
7 answers
953 views

Elegantly pairing up mismatched lists

HistogramList returns a list of bin boundaries and a list of counts. There is one more boundary than counts, and I'd like to pair them up so I can feed it into <...
20 votes
3 answers
2k views

Efficient way to combine SparseArray objects?

I have several SparseArray objects, say sa11, sa12, sa21, sa22, which I would like to combine into the equivalent of {{sa11, sa12}, {sa21, sa22}}. As an example, I ...
43 votes
5 answers
22k views

What is the most efficient way to add rows and columns to a matrix?

Say I have a matrix m and a vector v. ...
  • 19k
72 votes
9 answers
62k views

How to find the position of elements in a list satisfying criteria

Say I have a list x={2,4,6,8,10} and I want to find out the positions of the elements that are greater than 7. ...
  • 1,425
11 votes
5 answers
3k views

How do you efficiently return all of a List but one element?

I have a problem that I am working on that requires that I compare several lists of overlapping data points. As I traverse one of the lists, I'd like to only compare those data to the other lists, and ...
  • 33.4k
107 votes
4 answers
6k views

Flatten command: matrix as second argument

One thing I could never wrap my head around is how Flatten works when provided with a matrix as the second argument, and the Mathematica help isn't particularly ...
  • 14.7k
20 votes
7 answers
2k views

How to use Union on list of lists without sorting them first?

If I do ClearAll[a, d] lsts = {{a, d}, {a, d}}; Union[lsts] I get the expected answer {{a, d}} but if I do ...
  • 115k
21 votes
2 answers
2k views

Data Table Manipulation in Mathematica: Step 2

In this previous post (Data Table Manipulation in Mathematica) we find the brilliant suggestion proposed by Leonid Shifrin that allows to select specific rows identified by the header name. I'm now ...
  • 543
45 votes
3 answers
7k views

Data Table Manipulation in Mathematica

I am a statistician searching for an efficient way to select rows or columns from a table of data in Mathematica. Let me pose the question in 2 parts with a SQL-style table of data: ...
's user avatar

1
173 174 175 176
177