I have a matrix with three or more columns called mat
. I would like to map the second highest value in each row of mat
into its own list, and then take the mean of all the 2nd highest values. With only two rows, I managed to do this by using Min
, like this:
h = Map[Min, mat];
Mean[h]
How can I achieve this with three or more rows? I have tried to use RankedMin
and RankedMax
, but could not get them to work with the Map
function.
RankedMax::rvec: "Input {{0.757069},{0.211864}} is not a vector of reals or integers."
, and so on for each row inmat
. In this example the first row is{0.757069},{0.211864}
$\endgroup$mat
I usedTranspose
to cobine two other (single column) matrices $\endgroup${}
around each value, and your suggestion then works. Do you know a way to turn a matrix with columns of lists with numerical values into a normal matrix with columns of numerical values? ...Other than doing it manually? Or put differently, how to cobine all the single-column lists that I have into a normal matrix with many columns (not columns of lists)? $\endgroup$Flatten[]
on each list of values, and thenTranspose
to combine them into a many-column matrix. This worked. Thank you! $\endgroup$