Timeline for Average all rows of multiple columns with the same first column
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 2, 2016 at 13:30 | comment | added | Gray | Let us continue this discussion in chat. | |
| Sep 1, 2016 at 20:12 | comment | added | steeldriver | @Gray fwiw I've added a potential perl implementation - please note the disclaimer | |
| Sep 1, 2016 at 20:11 | history | edited | steeldriver | CC BY-SA 3.0 | added possible perl implementation |
| Sep 1, 2016 at 19:41 | comment | added | Gray | Thank you, steeldriver. I came up with a method to find out the global max value. datamash --sort --whitespace --header-in groupby 1 mean 2-4 < file | datamash --whitespace max 2-4 | perl -MList::Util=max -lane 'print max(@F)' | |
| Sep 1, 2016 at 19:30 | comment | added | steeldriver | I don't think there's any shortcut to finding the global max - you'll just have to make a separate traversal of the whole array. Although that's undoubtedly possible in awk, it's getting to the point where a more full-featured language such as perl might be simpler. Regarding datamash headers, I don't know a way to make it re-use the original ones (it seems to want to add its own summary header - or none). | |
| Sep 1, 2016 at 16:31 | comment | added | Gray | I want to divide all the values in the matrix by the largest value of all. By the way, how do I add the headers back as datamash removed it when processing the file. | |
| Sep 1, 2016 at 16:11 | comment | added | steeldriver | @Gray do you mean the largest value of all - or do you want to normalize the values in the 'a' row to the max of the 'a' row and the values in the 'b' row to the max of the 'b' row? | |
| Sep 1, 2016 at 15:34 | comment | added | Gray | Thank you again. One more question if you are still there. After averaging the values, how do I divide all the values with the largest value? In this case, the largest is 21.5. In real case, the largest value is not the last number. | |
| Sep 1, 2016 at 11:12 | vote | accept | Gray | ||
| Sep 1, 2016 at 3:44 | history | answered | steeldriver | CC BY-SA 3.0 |