by command to find out the maximum number from a list

Viewed 23714

I have a list like this :

Ll 
$a
3.4 5.6 -2.1 -7.8
$b
2.1 6.7
$c
-6.7,0.001,8.9

I want to find out the maximum number for all elements of the list irrespective of the signs. i.e. I want my out put to look like this :

Ll
$a
-7.8
$b
6.7
$c
8.9

Is there a way to do this through single command line ? Can it be done using the 'by' command?

3 Answers

which.max will give you index number and value, however if you need just number that you can try this:

max(sapply(yourlist, max))

Related