{"action":"created","issue":{"url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/issues/97","repository_url":"https://api.github.com/repos/HenrikBengtsson/matrixStats","labels_url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/issues/97/labels{/name}","comments_url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/issues/97/comments","events_url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/issues/97/events","html_url":"https://github.com/HenrikBengtsson/matrixStats/issues/97","id":224773809,"number":97,"title":"WISH: Add rowSums2() and rowMeans2() with mode support","user":{"login":"PeteHaitch","id":1049741,"avatar_url":"https://avatars0.githubusercontent.com/u/1049741?v=4","gravatar_id":"","url":"https://api.github.com/users/PeteHaitch","html_url":"https://github.com/PeteHaitch","followers_url":"https://api.github.com/users/PeteHaitch/followers","following_url":"https://api.github.com/users/PeteHaitch/following{/other_user}","gists_url":"https://api.github.com/users/PeteHaitch/gists{/gist_id}","starred_url":"https://api.github.com/users/PeteHaitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeteHaitch/subscriptions","organizations_url":"https://api.github.com/users/PeteHaitch/orgs","repos_url":"https://api.github.com/users/PeteHaitch/repos","events_url":"https://api.github.com/users/PeteHaitch/events{/privacy}","received_events_url":"https://api.github.com/users/PeteHaitch/received_events","type":"User","site_admin":false},"labels":[{"id":211176133,"url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/labels/feature%20request","name":"feature request","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-04-27T12:53:19Z","updated_at":"2018-04-30T15:31:33Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Opening a new issue for https://github.com/HenrikBengtsson/matrixStats/issues/82#issuecomment-297580797\r\n\r\nI'd like if `matrixStats::rowSums2()` and `matrixStats::colSums2()` supported a `mode` argument, as implemented in `matrixStats::sums2()`. \r\n\r\nDummy example:\r\n\r\n``` r\r\n# Toy data\r\nx <- matrix(1:10, ncol = 2)\r\nstr(x)\r\n#>  int [1:5, 1:2] 1 2 3 4 5 6 7 8 9 10\r\n\r\n# Expected output\r\nstr(matrixStats::colSums2(x, mode = \"integer\"))\r\n#> int [1:2] 15 40\r\nstr(matrixStats::colSums2(x, mode = \"double\"))\r\n#> num [1:2] 15 40\r\n```\r\n\r\nMy use case is performing row sums of a very long, skinny matrix with small integer entries. So I am basically certain the result will not overflow and returning an integer vector rather than a numeric/double vector halves the storage requirements of the return value.\r\n\r\nI'm unsure what the default value of `mode` should be. For consistency with `base::rowSums()` and `base::colSums()` would argue that `mode = \"double\"` should be the default. However, for consistency with `matrixStats::sum2()` it would be `mode = typeof(x)`.\r\n\r\nThanks for your consideration,\r\nPete"},"comment":{"url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/issues/comments/385435193","html_url":"https://github.com/HenrikBengtsson/matrixStats/issues/97#issuecomment-385435193","issue_url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/issues/97","id":385435193,"user":{"login":"HenrikBengtsson","id":1616850,"avatar_url":"https://avatars0.githubusercontent.com/u/1616850?v=4","gravatar_id":"","url":"https://api.github.com/users/HenrikBengtsson","html_url":"https://github.com/HenrikBengtsson","followers_url":"https://api.github.com/users/HenrikBengtsson/followers","following_url":"https://api.github.com/users/HenrikBengtsson/following{/other_user}","gists_url":"https://api.github.com/users/HenrikBengtsson/gists{/gist_id}","starred_url":"https://api.github.com/users/HenrikBengtsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HenrikBengtsson/subscriptions","organizations_url":"https://api.github.com/users/HenrikBengtsson/orgs","repos_url":"https://api.github.com/users/HenrikBengtsson/repos","events_url":"https://api.github.com/users/HenrikBengtsson/events{/privacy}","received_events_url":"https://api.github.com/users/HenrikBengtsson/received_events","type":"User","site_admin":false},"created_at":"2018-04-30T15:31:33Z","updated_at":"2018-04-30T15:31:33Z","author_association":"OWNER","body":"From [old notes of mine](https://github.com/HenrikBengtsson/matrixStats/issues/82#issuecomment-290282339):\r\n\r\n> * Contrary to `sum()`, `rowSums()` and `colSums()` always return a numeric and never integer overflows.  If the result is long and one want integer results that approach may be inefficient, e.g. `rowSums(x)` for a tall-and-narrow integer matrix.\r\n\r\nThus, one reason for `rowSums(x)` returning numeric values (=double) even also when `x` is integer, could be that it avoid any overflow of the sum."}}
{"actor":{"display_login":"HenrikBengtsson"}}