{"action":"created","issue":{"url":"https://api.github.com/repos/Rdatatable/data.table/issues/2930","repository_url":"https://api.github.com/repos/Rdatatable/data.table","labels_url":"https://api.github.com/repos/Rdatatable/data.table/issues/2930/labels{/name}","comments_url":"https://api.github.com/repos/Rdatatable/data.table/issues/2930/comments","events_url":"https://api.github.com/repos/Rdatatable/data.table/issues/2930/events","html_url":"https://github.com/Rdatatable/data.table/issues/2930","id":331422521,"node_id":"MDU6SXNzdWUzMzE0MjI1MjE=","number":2930,"title":"as.matrix.data.table incorrect results when nrows == 1","user":{"login":"malcook","id":484282,"node_id":"MDQ6VXNlcjQ4NDI4Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/484282?v=4","gravatar_id":"","url":"https://api.github.com/users/malcook","html_url":"https://github.com/malcook","followers_url":"https://api.github.com/users/malcook/followers","following_url":"https://api.github.com/users/malcook/following{/other_user}","gists_url":"https://api.github.com/users/malcook/gists{/gist_id}","starred_url":"https://api.github.com/users/malcook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malcook/subscriptions","organizations_url":"https://api.github.com/users/malcook/orgs","repos_url":"https://api.github.com/users/malcook/repos","events_url":"https://api.github.com/users/malcook/events{/privacy}","received_events_url":"https://api.github.com/users/malcook/received_events","type":"User","site_admin":false},"labels":[{"id":105265381,"node_id":"MDU6TGFiZWwxMDUyNjUzODE=","url":"https://api.github.com/repos/Rdatatable/data.table/labels/bug","name":"bug","color":"DF1A1C","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/Rdatatable/data.table/milestones/12","html_url":"https://github.com/Rdatatable/data.table/milestone/12","labels_url":"https://api.github.com/repos/Rdatatable/data.table/milestones/12/labels","id":3403867,"node_id":"MDk6TWlsZXN0b25lMzQwMzg2Nw==","number":12,"title":"1.11.6","description":"","creator":{"login":"jangorecki","id":3627377,"node_id":"MDQ6VXNlcjM2MjczNzc=","avatar_url":"https://avatars3.githubusercontent.com/u/3627377?v=4","gravatar_id":"","url":"https://api.github.com/users/jangorecki","html_url":"https://github.com/jangorecki","followers_url":"https://api.github.com/users/jangorecki/followers","following_url":"https://api.github.com/users/jangorecki/following{/other_user}","gists_url":"https://api.github.com/users/jangorecki/gists{/gist_id}","starred_url":"https://api.github.com/users/jangorecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jangorecki/subscriptions","organizations_url":"https://api.github.com/users/jangorecki/orgs","repos_url":"https://api.github.com/users/jangorecki/repos","events_url":"https://api.github.com/users/jangorecki/events{/privacy}","received_events_url":"https://api.github.com/users/jangorecki/received_events","type":"User","site_admin":false},"open_issues":27,"closed_issues":20,"state":"open","created_at":"2018-06-06T03:06:16Z","updated_at":"2018-08-14T01:53:57Z","due_on":null,"closed_at":null},"comments":18,"created_at":"2018-06-12T03:16:38Z","updated_at":"2018-08-14T03:07:31Z","closed_at":null,"author_association":"NONE","body":"`#` [`Minimal reproducible example`](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)\r\n\r\n``` r\r\nlibrary(data.table)\r\nd<-data.table(name=c(\"bob\",\"joe\"),age=10:11,IQ=c(130,140))\r\nas.matrix(d, 1) \r\n#>     age  IQ\r\n#> bob  10 130\r\n#> joe  11 140\r\n\r\nas.matrix(d[1, ], 1)\r\n#>   name  age  IQ   \r\n#> 1 \"bob\" \"10\" \"130\"\r\n```\r\n\r\n<sup>Created on 2018-06-13 by the [reprex package](http://reprex.tidyverse.org) (v0.2.0).</sup>\r\n\r\n\r\nThe problem is that the rownames argument to as.matrix.data.table is not being respected as documented:\r\n\r\n\r\n> `rownames`: optional, a single column name or column index to use as the\r\n          'rownames' in the returned 'matrix'. If 'TRUE' the 'key' of\r\n          the 'data.table' will be used if it is a single column,\r\n          otherwise the first column in the 'data.table' will be used.\r\n          Alternative a vector of length 'nrow(x)' to assign as the row\r\n          names of the returned 'matrix'.\r\n\r\nWe should expect  the 2nd call above  to yield a 1x2 matrix of numeric having the single rowname of \"bob\".  Instead, it yields a 1x3 character matrix.\r\n\r\n```\r\nR version 3.4.3 (2017-11-30)\r\nPlatform: x86_64-pc-linux-gnu (64-bit)\r\nRunning under: CentOS Linux 7 (Core)\r\n\r\nMatrix products: default\r\nBLAS: /n/apps/CentOS7/install/r-3.4.3/lib64/R/lib/libRblas.so\r\nLAPACK: /n/apps/CentOS7/install/r-3.4.3/lib64/R/lib/libRlapack.so\r\n\r\nlocale:\r\n[1] C\r\n\r\nattached base packages:\r\n[1] stats     graphics  grDevices utils     datasets  methods   base     \r\n\r\nother attached packages:\r\n[1] data.table_1.11.2 devtools_1.13.5  \r\n\r\nloaded via a namespace (and not attached):\r\n[1] compiler_3.4.3 withr_2.1.2    memoise_1.1.0  digest_0.6.15\r\n```"},"comment":{"url":"https://api.github.com/repos/Rdatatable/data.table/issues/comments/412739795","html_url":"https://github.com/Rdatatable/data.table/issues/2930#issuecomment-412739795","issue_url":"https://api.github.com/repos/Rdatatable/data.table/issues/2930","id":412739795,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjczOTc5NQ==","user":{"login":"mattdowle","id":2779998,"node_id":"MDQ6VXNlcjI3Nzk5OTg=","avatar_url":"https://avatars3.githubusercontent.com/u/2779998?v=4","gravatar_id":"","url":"https://api.github.com/users/mattdowle","html_url":"https://github.com/mattdowle","followers_url":"https://api.github.com/users/mattdowle/followers","following_url":"https://api.github.com/users/mattdowle/following{/other_user}","gists_url":"https://api.github.com/users/mattdowle/gists{/gist_id}","starred_url":"https://api.github.com/users/mattdowle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattdowle/subscriptions","organizations_url":"https://api.github.com/users/mattdowle/orgs","repos_url":"https://api.github.com/users/mattdowle/repos","events_url":"https://api.github.com/users/mattdowle/events{/privacy}","received_events_url":"https://api.github.com/users/mattdowle/received_events","type":"User","site_admin":false},"created_at":"2018-08-14T03:07:31Z","updated_at":"2018-08-14T03:07:31Z","author_association":"MEMBER","body":"In further agreement with @malcook, for even further clarity, safety and consistency, I've suggested a minor change to @sritchie73's PR here: https://github.com/Rdatatable/data.table/pull/2939#issuecomment-412736549.  I'll make the change to the PR unless there are any objections."}}
{"actor":{"display_login":"mattdowle"}}